自动配置文件更改器应用程序显示安全性异常:权限拒绝:不允许发送广播android.intent.action.Planet\u模式
我正在开发一个android应用程序,在这个程序中,我想自动将个人资料从铃声模式更改为飞行模式。应用程序在android 2.3到4.2上运行良好,但在4.4 kitkat上不起作用。 Logcat显示此错误自动配置文件更改器应用程序显示安全性异常:权限拒绝:不允许发送广播android.intent.action.Planet\u模式,android,broadcastreceiver,android-4.4-kitkat,android-permissions,android-securityexception,Android,Broadcastreceiver,Android 4.4 Kitkat,Android Permissions,Android Securityexception,我正在开发一个android应用程序,在这个程序中,我想自动将个人资料从铃声模式更改为飞行模式。应用程序在android 2.3到4.2上运行良好,但在4.4 kitkat上不起作用。 Logcat显示此错误 java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid 我已经添加了以下权限 <uses-p
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid
我已经添加了以下权限
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
//
//
请解决我的问题,谢谢谷歌一直在逐步锁定这些系统广播,因此应用程序无法发送它们。此广播从未被设计为由SDK应用程序发送,切换飞行模式会影响隐私和安全,和许多其他人一样,has:“这是一个受保护的意图,只能由系统发送。”谢谢,但什么是替代解决方案?希望没有替代解决方案。如前所述,切换飞机模式会影响隐私和安全。
Airplane_mode(false);
public void Airplane_mode(boolean isEnabled) {
if (isEnabled) {
Settings.System.putInt(this.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 1);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", isEnabled);
sendBroadcast(intent);
} else if (!isEnabled) {
Settings.System.putInt(this.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0);
Settings.System.putInt(this.getContentResolver(),
Settings.System.AIRPLANE_MODE_RADIOS, 1);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", isEnabled);
sendBroadcast(intent);
}
}
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", isEnabled);
sendBroadcast(intent);