0
シェルコマンドを実行するアンドロイドアプリケーションを作成しようとしています。これが望ましい場合はシェルスクリプトを作成し、出力を表示します。私は正しい方向に?次のようにRE:Androidアプリケーションからシェルスクリプトファイルを実行するにはどうすればいいですか?
私のコードは次のとおりです。
void execCommandLine()
{
Runtime runtime = Runtime.getRuntime();
Process proc = null;
OutputStreamWriter osw = null;
try
{
String[] str={"/system/bin/sh","/data/shTest.sh"};
System.out.println("EXEC STRING");
proc = runtime.exec(str);
osw = new OutputStreamWriter(proc.getOutputStream());
//osw.write(command);
osw.flush();
osw.close();
}
catch (IOException ex)
{
Log.e("erre","ioexception");
//Log.e("execCommandLine()", "Command resulted in an IO Exception: " + command);
return;
}
finally
{
if (osw != null)
{
try
{
osw.close();
}
catch (IOException e){}
}
}
try
{
proc.waitFor();
}
catch (InterruptedException e){}
if (proc.exitValue() != 0)
{
Log.e("erre","interruotexception");
//Log.e("execCommandLine()", "Command returned error: " + command + "\n Exit code: " + proc.exitValue());
}
}
// **************************************
コードが正常に実行されているが、私は、このスクリプトは、この出力を取得する方法を正常に実行された場合、誰が私に言うだろうadbのシェルlogcat における任意の出力を取得しておりませんAdbシェルの