Modify AIRPLANE_MODE_ON on Android 4.2 (and above)

后端 未结 2 1008
花落未央
花落未央 2020-12-09 05:36

Since the sdk version 4.2 it seems like it\'s no longer possible to modify airplane-mode on devices since google has moved this setting to Settings.Global which is read-only

2条回答
  •  温柔的废话
    2020-12-09 05:57

    I know you explicitly ask for a solution without rooting, but if you have a rooted device there is at least the (kind of) official solution to move your app into folder /system/app. Then it is possible to write into Settings.Global:

    Settings.Global.putInt(context.getContentResolver(), Global.AIRPLANE_MODE_ON, mode ? 1 : 0);
    

    Have a look of how to toggle airplane mode for 4.2 and how to move your app into /system/app here. I use this for my toggle widget Mini Status (source code link).

提交回复
热议问题