重新启动手机上的一个按钮点击重新启动、机上、按钮

2023-09-12 09:38:21 作者:看流年

我想提出一个Android应用程序,需要有手机重启或关闭一个按钮被点击时。这可能吗?或者将手机需要root权限?

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?

推荐答案

您可以做,使用 android.os.PowerManager 。功能重启(字符串的原因)是可用的,你需要的权限:

You can do that using android.os.PowerManager. Function reboot(String reason) is available, you need permission:

android.permission.REBOOT

官方网站:

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

当然,你很可能得到只有当你的应用程序与系统的签名密钥签名的权限:

Of course, you are likely to get that permission only if your application is signed with the system signing key:

How编译系统权限的Andr​​oid应用程序