【发布时间】:2013-10-25 10:40:23
【问题描述】:
我在 android 4.3 版中遇到了通过代码控制飞行模式的问题。为此,我使用谷歌播放中提供的系统/应用程序移动应用程序将用户应用程序转换为系统。一旦用户启用飞行模式,后台服务可以控制检查飞行模式并将其重置为关闭状态并将广播更改发送到设备。在我在代码中实现的 sn-p 下方以保持飞行模式状态处于关闭状态。但它在 android 版本 4.3 中失败.它抛出一个称为“权限被拒绝”的异常。让我知道这些是否需要在清单中添加任何额外的权限,或者让我知道您对这些问题的修复建议。
try {
Settings.Global.putInt(context.getContentResolver(),
"airplane_mode_on", 0);
isAirplaneModeOn = isAirplaneModeOn(context);
Intent localIntent2 = new Intent(
"android.intent.action.AIRPLANE_MODE");
localIntent2.putExtra("state", isAirplaneModeOn);
context.sendBroadcast(localIntent2);
} catch (Exception e) {
Log.v("TAG",
e.toString() + "\n" + e.getMessage());
}
【问题讨论】:
标签: android