[英]Android airplane mode API lvl 17 toggle
Since api lvl 17 airplane mode setting was moved from Settings.System to Settings.Global 由于api lvl 17飞行模式设置已从Settings.System移至Settings.Global
Problem is that now i can't switch setting anymore. 问题是现在我不能再切换设置了。 API description is that those settings are read only.
API描述是这些设置是只读的。 Did anyone manage to find a way to change it?
有没有人设法找到改变它的方法?
Pre API lvl 17 code that worked: 有效的Pre API lvl 17代码:
Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1);
API lvl 17 code that I tried and doesn't work : API lvl 17我尝试过但不起作用的代码:
Settings.Global.putInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, setMode);
It throws exception (documentation says it should throw silent log error): 它抛出异常(文档说它应该抛出静默日志错误):
11-14 13:39:51.649: E/AndroidRuntime(3509): java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
but I have this permission in manifest : 但我在清单中有这个许可:
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
If anyone knows a way to solve this that would be awesome!! 如果有人知道解决这个问题的方法会很棒!!
WRITE_SECURE_SETTINGS
is a signature|system
permission, which can only be held by apps that are signed with the firmware's signing key or reside on the system partition. WRITE_SECURE_SETTINGS
是signature|system
权限,只能由使用固件签名密钥签名或驻留在系统分区上的应用程序保留。 Hence, while you can ask for it, you cannot hold it. 因此,虽然你可以要求它,但你不能坚持它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.