これが私が作ろうとしているものの例です:
final String[] hwdebug1 = {"su","-c","echo hello > /system/hello1.txt"};
try {
Runtime.getRuntime().exec(hwdebug1);
} catch (IOException e) {
}
したがって、ボタンをクリックすると完全に機能しますが、たとえば、次のようなことをすると機能しません。
final String[] hwdebug1 = {"su","-c","echo hello > /system/hello1.txt","echo hello > /system/hello2.txt","echo hello > /system/hello3.txt"};
私の意図は、ボタンに複数のコマンドを実行させることです。私はすでにbashスクリプトを実行させることでそれを実行しましたが、コードに配置する方法を見つけることを好みます。
ありがとう!
Ben75メソッドで解決
final String[] hwdebug1 = {"su","-c","echo hello > /system/hello1.txt"};
final String[] hwdebug2 = {"su","-c","echo hello > /system/hello2.txt"};
final String[] hwdebug3 = {"su","-c","echo hello > /system/hello3.txt"};
ArrayList<String[]> cmds = new ArrayList<String[]>();
cmds.add(hwdebug1);
cmds.add(hwdebug2);
cmds.add(hwdebug3);
for(String[] cmd:cmds){
try {
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStacktrace();
}
}