在android中获取关机或重启的权限 [英] Obtain the permission of shutdown or restart in android

查看:17
本文介绍了在android中获取关机或重启的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建关闭/重启功能.

I am creating a shutdown/restart function.

    Intent intent = new Intent();  
    intent.setAction("android.intent.action.ACTION_SHUTDOWN");  
    sendBroadcast(intent); 

在xml中:

<uses-permission  android:name="android.permission.SHUTDOWN"/>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="org.crazyit.net"
  android:versionCode="1"
  android:versionName="1.0" 
  android:sharedUserId="android.uid.system">

但它在用户权限中有这个错误:权限仅授予系统应用.

But it has this error in users-permission:permission is only granted to system apps.

有什么想法吗?

推荐答案

如错误信息所述,普通应用无法获得此权限.这将是一个安全风险,因为您可能会构建一个使手机无法使用的应用程序.

As the error message explains, a normal app cannot get this permission. It would be a security risk since you could build an application that renders the phone useless.

这篇关于在android中获取关机或重启的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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