How to Reboot phone programmatically?

前端 未结 5 1424
情深已故
情深已故 2021-01-17 04:27

I am creating app(only for Android 6) in which I have to give reboot functionality using button click. I am using following code:

PowerManager pm =(PowerMan         


        
5条回答
  •  醉梦人生
    2021-01-17 05:26

    if you running Android M (API 23) you have to set runtime permission for reboot.

    If the device is running Android 6.0 or higher, and your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. The user can grant or deny each permission, and the app can continue to run with limited capabilities even if the user denies a permission request.

    Requesting Permissions at Run Time

提交回复
热议问题