[fpc-pascal] Re: FPC programs in Android without JNI

Jeppe Johansen jepjoh2 at es.aau.dk
Tue Dec 28 04:17:01 CET 2010

Den 18-12-2010 11:13, Felipe Monteiro de Carvalho skrev:
> ahahah, I was writing an answer in my phone, but then gave up.
> Probably hit the send button by accident.
> Anyway, yes, I had also seen that one and it is a step in the right direction =)
> I haven't yet fully understood how this new APIs work, hopefully they
> are C APIs, if they are C++ APIs then it is just better to make Java
> calls like I can already do now. Another problem is that it doesn't
> solve the main issue which is that Android does not officially support
> running native programs, they need to be libraries. Of course I
> ignored this and managed to run native programs, but that's another
> story.
> In short I don't think that I will change my development strategy for
> now, specially since I already bought a Android 2.1 phone and I can
> write Pascal apps for it at the moment and I don't plan on dropping
> support for it at the moment.
> Of course that I might migrate to use this newer possibilities when I
> have exhausted that my current strategy can provide =)
They are C APIs indeed. I just took a stab at it, and after a long day 
of pointer errors in converted C code and really, really badly 
descriptions of error messages, I managed to port the example from here 
to FPC

Code here: http://j-software.dk/android.zip
Simply run lazbuild test.lpi in the jni dir, and then run ant debug/ant 
install in the root dir

The NativeActivity class allows you to load a shared library and run an 
exported method without any Java code at all. Then it's just a matter of 
converting all the required Android headers, and repurposing the 
existing Unix units(lots of libnames are different) and you can have a 
pretty non-hacky interface to lowlevel stuff from FPC.

Of course this doesn't solve any of the user interface problems, but I'm 
pretty sure it's a way better solution than copying applications and 
piping data to and from them

More information about the fpc-pascal mailing list