I have been trying to implement the API for the serial port found the the below web page. I am a beginner in all this and I am sure about what I am looking at:
Questions:
1) The .c files are built how? Do I need to download the NDK? I assume the .c file is run directly by the virtual machine, or what? Or is the executable for the .c the file in the libs directory? If so, how do I utilize the libserial_por.so file?
Thanks!
The .c files are built into a library by running
ndk-buildin the project directory. You need the NDK.The .c files are not run directly by the virtual machine, but rather a library is created in the
libsdirectory, which is then loaded along with theSerialPortclass.To use the library, just use the
SerialPortclass which already has bindings to the library.C files will be compiled to an ARM binary library with the extension .so by the NDK. Take a look at the NDK Documentation, section “Getting Started with the NDK”, to find out how to use it.
Basically, you place your .c files in the
jnidirectory, changeAndroid.mkto specify how to compile them, then runndk-buildto build the library. The resultinglib<name>.sowill be placed in thelibdirectory. You then use your library in the Java project withSystem.loadLibrary('<name>').This of course means the library must have a JNI interface for you to be able to use with the Java application, since Android doesn’t support JNA yet.
I see though that the code you pointed out is an Android project. To run it, simply run
ndk-buildin the project directory to build the library, then run the project in an emulator.