我试图在Android Terminal Emulator上运行命令。我有我的设备根植,我安装了superuser.apk。运行命令Android终端模拟器。安装按代码安装
我做这样的:
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();
}
而且也很好:
try {
Process process = Runtime.getRuntime().exec(<b>cmd</b>*);
process.waitFor();
} catch (Exception e){
e.printStackTrace();
}
我试图安装一个。 Apk通过代码。我尝试了以下方法:
cmd =>pm install /mnt/sdcard/app.apk
没有任何结果。
在cmd =>su -c "pm install /mnt/sdcard/app.apk"
随着单引号,双quoutes和无引号。结果:
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
其他命令状LS运行正常。
如何安装位置在/ mnt/SD卡的APK?
谢谢!
它不起作用。我找到了解决方案。见下文。 – Ricmcm 2012-07-20 07:42:11