I have a C command line executable that I have successfully compiled for Android. I can copy the executable and launch it with Android Terminal Emulator on my Android ICS phone by doing the following:
Step one is necessary because the command line application makes use of the ncurses library and if i do not set TERMINFO then I get an error when I try launch the application. If I leave off the second step then I get an "Access denied" when I try launch the command line application from the sdcard. So, provided I manually do these steps I can launch the command line executable.
Now what I am wanting to do is to wrap this command line executable inside a standard Android application. The source for Android Terminal Emulator is open source and so I can use that to open an EmulatorView inside my Android application. My question though is how do I go about including the native executable inside the apk, deploying it to the device in a location where my application will have rights to execute it in the EmulatorView. I am a bit concerned about whether I will be able to get over the rights issue so that the native command line executable can be launched.
I do know about the Android NDK, but would prefer not to have to re-write a working command line application so that it can be included as a library. I am specifically looking at keeping the C executable source as it is and executing it from the wrapper application. Does anyone know whether this is possible and if so how I would go about doing it?
If you copied the native file under your data folder where you should have appropriate permission, and then use Runtime.exec to execute your file.
You can create a bin folder (or any name) and copy your file under
Process exeProcess =
Runtime.getRuntime().exec("/data/data/YOUR_PACKAGE/bin/EXECUTABLE_FILE");
You can use the object exeProcess to read the data from your executable file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With