はlike thisをお試しください:
try {
Runtime r = Runtime.getRuntime();
Process process = r.exec(" su -c 'echo -e \"AT\\r\" > /dev/smd0; cat /dev/smd0' ");
BufferedReader in = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
はまたあなたの携帯電話へのrootアクセスを必要としています。我々は、コマンドを送信するためにDataOutPutStream
を使用する必要がsu
を必要とするもの、コマンドの最後に、いくつかのコマンドのために必要な
Runtime r = Runtime.getRuntime();
Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(
process.getOutputStream());
os.writeBytes("echo -e \"AT\\r\" > /dev/smd0\n");
os.flush();
os.writeBytes("exit\n");
os.flush();
\n
:
上記で提供した同じリンクで、行:文字列currUid = osRes.readLine(); – Muzikant