shut down android device programmatically

前端 未结 2 1192
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 01:27

I am trying to switch off android device through my program. It actually gets switched off but it restarts itself. I want the phone not to restart again by itself. How can I

相关标签:
2条回答
  • 2020-12-20 01:34

    I suppose you have found the answer,but this might help other users.

    It's not possible to turn off your device. Here is an easy way to lock it :

    • Download an application that locks/turns off the screen
    • Launch it from your application Launch an application from another application on Android

    You won't need any permissions, because some are only granted for system apps(like DEVICE_POWER and REBOOT). You also won't need to root your device.

    0 讨论(0)
  • 2020-12-20 01:46

    This has been asked on StackOverflow in the past. The effective answer is that you would require the DEVICE_POWER permission in order to shut the phone completely off, but the user would need a rooted phone to give your app permission to that control anyway.

    Best you could hope for is PowerManager.goToSleep()

    0 讨论(0)
提交回复
热议问题