C command line wrapping done in standard Android app

I have a C command line executable that I have successfully compiled for Android. I can copy the executable and run it using Android Terminal Emulator

on my ICS Android phone by following these steps:

  • execute "export TERMINFO = / etc / terminfo"
  • execute "mount -o remount rw / sdcard"
  • run executable file from SD card

Step one is necessary because the command line application uses the ncurses library, and if I don't install TERMINFO then I get an error when I try to start the application. If I move away from the second step, I get Access Denied when I try to run the command line application from the SD card. So if I do these steps manually, I can run the command line executable.

Now what I want to do is wrap this executable command line inside a standard Android app. The source for Android Terminal Emulator

is open source, so I can use it to open EmulatorView

inside my android app. My question is how can I include my own executable internally apk

by deploying it to the device in the location where my application will have permission to execute it in EmulatorView

. I'm a bit concerned about whether I can resolve the permissions issue to run my own command line executable.

I know about the Android NDK, but would prefer not to rewrite a working command line application so that it can be included as a library. I am specifically looking at keeping the C executable as is and executing it from a wrapper application. Does anyone know if this is possible and if so how would I go about doing it?

+3


source to share


1 answer


If you copied the file native

to the data folder where you must have the appropriate permission, then use Runtime.exec

to execute your file.

You can create a folder bin

(or any name) and copy the file under



Process exeProcess = 
         Runtime.getRuntime().exec("/data/data/YOUR_PACKAGE/bin/EXECUTABLE_FILE");

      

You can use an object exeProcess

to read data from an executable file.

+1


source







All Articles