if(Settings.System.getString(getActivity().getContentResolver(),Settings.Global.AIRPLANE_MODE_ON).equals("0")) { Settings.System.putInt(getActivity().getContentResolver(),Settings.Global.AIRPLANE_MODE_ON,1); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state",true); getActivity().sendBroadcast(intent); Log.i(TAG,"airplane on"); } else { Settings.System.putInt(getActivity().getContentResolver(), Settings.Global.AIRPLANE_MODE_ON,0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state",false); getActivity().sendBroadcast(intent); Log.i(TAG,"airplane off"); } 这个权限有警告,这是因为只有系统程序才能有这个权限,我的程序是普通程序不能写这个权限要求,写了也没有用。 当在我的手机(android5.1.1)上运行时报异常: java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=928, uid=10118

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐