android - 单击按钮重新启动手机

标签 android powermanager

我正在制作一个 Android 应用程序,需要在单击按钮时让手机重启或关闭。这可能吗?还是手机需要 root 权限?

最佳答案

您可以使用 android.os.PowerManager 来做到这一点。函数 reboot(String reason) 可用,您需要权限:

android.permission.REBOOT

官方网站:

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

当然,只有当您的应用程序使用系统签名 key 签名时,您才有可能获得该权限:

How to compile Android Application with system permissions

关于android - 单击按钮重新启动手机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4966486/

相关文章:

android - 与 Android 相比,Phonegap 或 HTML5 有哪些限制和缺点

android - 如何使用 MapFragment(而非 MapView)获取 map 的坐标?

android - UPnP 设备库 : android

android - 华为系统设置的最新自动启动 Activity Intent 是什么?

Android isScreenOn Nullpointer异常

android - map View 安卓 :clickable ="false" not working?

android - 是否可以将隐藏的小部件导出为图像?

android - 如何使用 PowerManager.ACQUIRE_CAUSES_WAKEUP

android - "PowerManger.FULL_WAKE_LOCK is deprecated"是什么意思?