Reboot the phone on a button click

后端 未结 3 697
广开言路
广开言路 2020-12-01 14:55

I am making an Android app that needs to have the phone reboot or turn off when a button is clicked. Is this possible? Or will the phone require root access?

3条回答
  •  孤街浪徒
    2020-12-01 15:33

    If your device is rooted device then you can use below code.

    Runtime.getRuntime().exec(new String[]{"/system/bin/su", "-c", "reboot now"});
    

提交回复
热议问题