简体   繁体   中英

Android airplane mode API lvl 17 toggle

Since api lvl 17 airplane mode setting was moved from Settings.System to Settings.Global

Problem is that now i can't switch setting anymore. API description is that those settings are read only. Did anyone manage to find a way to change it?

Pre API lvl 17 code that worked:

Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1);

API lvl 17 code that I tried and doesn't work :

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. Hence, while you can ask for it, you cannot hold it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM