重新启动手机上的一个按钮点击 [英] Reboot the phone on a button click

查看:160
本文介绍了重新启动手机上的一个按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个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

官方网站:

<一个href="http://developer.android.com/reference/android/os/PowerManager.html#reboot(java.lang.String">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:

<一个href="http://stackoverflow.com/questions/3598662/how-to-compile-android-application-with-system-permissions">How编译系统权限的Andr​​oid应用程序

这篇关于重新启动手机上的一个按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆