android7.0 使用shell命令能重启为什么不能关机?

android7.0 使用shell命令能重启为什么不能关机?

可以这样:

 adb shell reboot -p

p是power off的意思。

如果对您有帮助,请采纳答案好吗,谢谢!

可以这样:
adb shell reboot -p
二楼回答是正确的。

Process proc = null; //关机
// try {
// proc = Runtime.getRuntime().exec(new String[]{"adb","shell","reboot -p"});
// proc.waitFor();
// } catch (IOException e) {
// e.printStackTrace();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }

比方说这种,就能重启,但是关机就没反应。

自己解决了,

private void MyShutDown()
{
try
{
Process process=Runtime.getRuntime().exec("reboot -p");

    String data=null;
    BufferedReader errorLine=new BufferedReader(new InputStreamReader(process.getErrorStream()));
    BufferedReader inputLine=new BufferedReader(new InputStreamReader(process.getInputStream()));

    String error=null;
    while ((error=errorLine.readLine())!=null&&!error.equals("null"))
    {
        data+=error+"\n";
    }

    String input=null;
    while((input= inputLine.readLine())!=null&&!input.equals("null"))
    {
        data+=input+"\n";
    }

}
catch (Exception e)
{

}

}