简体   繁体   English

嘿,我才刚开始在android中进行编码并收到错误Permission Denial:不允许在android中发送广播

[英]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.

相关问题 应用程序因 Permission Denial 崩溃:不允许发送广播 android.intent.action.SCREEN_ON - App crashes with Permission Denial: not allowed to send broadcast android.intent.action.SCREEN_ON Android Studio权限拒绝 - Android Studio Permission Denial android 工作室中的权限拒绝 - permission denial in android studio 我刚开始使用android,但在使用reverseWord方法时遇到了麻烦 - I just started using android and am having trouble with a reverseWord method 如何使用 HttpURLConnection for java android 发送身份验证密钥? 我收到错误代码 500 - How to send authentication key using HttpURLConnection for java android? I am getting error code 500 日历提供程序:Android 8上的权限拒绝 - Calendar Provider: Permission Denial on Android 8 使用广播接收器拒绝权限 - Permission Denial With Broadcast Receiver RuntimeException 无法启动活动:权限被拒绝:来自 android 的广播要求以用户 -1 的身份运行,但从用户 0 调用 - RuntimeException Unable to start activity: Permission Denial: broadcast from android asks to run as user -1 but is calling from user 0 显示 Android 自动化错误:“安全异常:权限拒绝:启动意图” - Android Automation Error Displayed: "Security exception: Permission Denial: starting Intent" 为什么我的Android代码中出现空指针错误? - Why am I getting a null pointer error in my Android Code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM