Androidターミナルエミュレータでコマンドを実行しようとしています。デバイスをルート化し、 superuser.apkをインストールしました。
私はこのようにやっています:
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"
一重引用符、二重引用符、引用符なし。結果:
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 / sdcardにあるapkをインストールするにはどうすればよいですか?
ありがとう!