[英]Hey , I am just started to code in android and getting error Permission Denial: not allowed to send broadcast in android
permission denial
My activity code is 我的活动代码是
boolean isEnable= Settings.System.getInt(getContentResolver(),Settings.System.AIRPLANE_MODE_ON,0)==1;
Settings.System.putInt(getContentResolver(),Settings.System.AIRPLANE_MODE_ON,isEnable?0:1);
intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state",!isEnable);
sendBroadcast(intent);
That is because ordinary SDK apps cannot send ACTION_AIRPLANE_MODE_CHANGED
broadcasts. 那是因为普通的SDK应用程序无法发送ACTION_AIRPLANE_MODE_CHANGED
广播。 If you look at the documentation for that Intent
action , you will see: 如果您查看有关该Intent
操作的文档 ,则会看到:
This is a protected intent that can only be sent by the system. 这是受保护的意图,只能由系统发送。
Also note that your AIRPLANE_MODE_ON
stuff may not work on API Level 17 (Android 4.2) or higher devices . 另请注意,您的AIRPLANE_MODE_ON
内容可能不适用于API级别17(Android 4.2)或更高版本的设备 。
And, note that ordinary SDK apps cannot hold the WRITE_SETTINGS
permission. 并且,请注意,普通的SDK应用程序无法拥有WRITE_SETTINGS
权限。 If you are building your own custom Android ROM, you could have apps that hold that permission in that ROM. 如果您要构建自己的自定义Android ROM,则可以使用在该ROM中拥有该权限的应用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.