80,351
社区成员
发帖
与我相关
我的任务
分享
private void doBackKey(){
/* try ///第一种方案.
{
Process localProcess = Runtime.getRuntime().exec("su");
DataOutputStream localDataOutputStream = new DataOutputStream(localProcess.getOutputStream());
localDataOutputStream.writeBytes("input keyevent 4\n");
localDataOutputStream.flush();
localDataOutputStream.close();
localProcess.waitFor();
/// String str = new DataInputStream(localProcess.getErrorStream()).readLine();
localProcess.destroy();
}
catch (Exception localException)
{
Log.i("snoeeee",localException.getMessage().toString());
Toast.makeText(MainActivity.this,localException.getMessage().toString(), Toast.LENGTH_LONG).show();
}
*/
Process pro; ////这个是第二种方案
try {
pro = Runtime.getRuntime().exec("input keyevent 4\n");
try {
pro.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}