I'm trying to run commands on the Android Terminal Emulator. I have my device rooted and I installed superuser.apk.
I'm doing it like this:
try {
Process process = Runtime.getRuntime().exec(cmd);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = bufferedReader.readLine();
while ( line != null ) {
Log.i("SHELL", line);
line = bufferedReader.readLine();
}
} catch ( Exception e) {
e.printStackTrace();
}
And also well:
try {
Process process = Runtime.getRuntime().exec(<b>cmd</b>*);
process.waitFor();
} catch ( Exception e ){
e.printStackTrace();
}
I'm trying to install a. Apk by code. I tried the following:
cmd => pm install /mnt/sdcard/app.apk
Without any results.
cmd => su -c "pm install /mnt/sdcard/app.apk"
With single quotes, double quoutes and no quotes. Result:
I/SHELL(1432): Usage: su [options] [LOGIN]
I/SHELL(1432): Options:
I/SHELL(1432): -c, --command COMMAND pass COMMAND to the invoked shell
I/SHELL(1432): -h, --help display this help message and exit
I/SHELL(1432): -, -l, --login make the shell a login shell
I/SHELL(1432): -s, --shell SHELL use SHELL instead of the default in passwd
I/SHELL(1432): -v, --version display version number and exit
I/SHELL(1432): -V display version code and exit. this is
I/SHELL(1432): used almost exclusively by Superuser.apk
Other commands like ls runs fine.
How I can install an apk located in /mnt/sdcard?
Thanks!
try this :
su -c "pm install /mnt/sdcard/app.apk" root
But i think, it doesn't work if you have no root your phone