2

I'm trying to turn airplanemode on on Android but I got the following message:

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE

From my point of view (and some researches):

(1) I'm using all necessary permission to do that:

<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />

(2) The code is not wrong:

        Settings.Global.putInt(
                context.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_ON, 1);
        Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        intent.putExtra("state", true);
        context.sendBroadcast(intent);

I know that the app needs to be installed as a system app, so I'm installing that under /system/app/my-app/ (I tried /system/priv-app/my-app/ too) and added all the permissions to the folder and to the apk.

The last thing that I tried was the include of android:sharedUserId="android.uid.system" at the AndroidManifest.xml, but doing that the application disappears.

What am I missing here, after all those attempts?

ps: The device is rooted.

Thanks in advance

brvboas
  • 29
  • 1
  • 4

1 Answers1

-1

It seems although Airplane Mode has become a Constant value as of API Level 17 as per the Android development documentation.

Why are you turning airplane mode on? Is there a certain functionality you are trying to accomplish?

I would've posted this in the comments, but I don't have enough rep... tfw

Tyler Dickson
  • 473
  • 1
  • 7
  • 24
  • Take a look at [this](http://stackoverflow.com/questions/25674655/how-to-turn-on-off-airplane-mode-even-on-new-android-versions-and-even-with-ro), it should solve your problem – Tyler Dickson Aug 31 '16 at 15:52