且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式关闭Android手机?

更新时间:2022-04-28 01:11:49

您可以使用PowerManager使其重新启动(这不能保证它将重新启动-操作系统可能会取消它):

You could possibly use the PowerManager to make it reboot (this does not guarantee that it'll reboot - OS may cancel it):

http://developer.android. com/reference/android/os/PowerManager.html#reboot(java.lang.String )

它需要REBOOT许可:

It requires the REBOOT permission:

http://developer.android.com/reference/android/Manifest.permission.html#REBOOT

在尝试启用/禁用键盘锁时,您还可以检查您的logcat并发布其中的内容吗?

Can you also check your logcat when trying to enable/disable keyguard, and post what's there?

您不能通过普通的SDK应用程序执行此操作.只有使用系统固件签名密钥签名的应用程序才能执行此操作

You cannot do this from an ordinary SDK application. Only applications signed with the system firmware signing key can do this