Welcome to the Android Central Forums Create Your Account or Ask a Question Answers in 5 minutes - no registration required!
Results 1 to 3 of 3
  1. Thread Author  Thread Author    #1  
    ohan's Avatar

    Posts
    1 Posts

    Default Turning on/off Airplane mode as system app

    Hi,

    I've encountered a very strange problem for programmatically turning on/off the airplane mode.
    I'm aware that it's one of the secure settings, and my app is a system app that is correctly signed.

    However, I'm not able to correctly turn on/off the airplane mode.
    I have the following codes: (checked value is from onCheckedChanged callback of a check box UI)

    int isAirplaneModeOn = checked ? 1 : 0;
    Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, isAirplaneModeOn);
    Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    intent.putExtra("state", checked);
    mContext.sendBroadcast(intent);

    The line where it calls Settings.Global.putInt(....) works, because we can see that the airplane mode's check box in the android's settings app will changes as we change this value from our app, so we know that our app is indeed a system app. Otherwise, it will throw a SecurityException at this line.

    However, we're getting "Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE", at the line where it calls mContext.sendBroadcast(...). I have no idea why this fails while Settings.Global.putInt works.

    One last note is that we're using Android 4.4.2 (KitKat).

    Any help will be appreciated

    Thanks
  2. #2  

    Default Re: Turning on/off Airplane mode as system app

    Hi Ohan!

    Were you able to resolve your problem? If so, could you please share the solution.

    Thanks!
    Gagan
  3. #3  

    Default Re: Turning on/off Airplane mode as system app

    Hi I have the same issue .. SO if you had any solution for this please share it.. Will be grateful to you..

Similar Threads

  1. Quite mode problems
    By bfuels1993 in forum AT&T LG G2
    Replies: 16
    Last Post: 07-09-2014, 12:15 PM
  2. Replies: 6
    Last Post: 03-18-2014, 08:32 PM
  3. I've deleted my android operating system on Galaxy Fit. HELP!
    By Alexghe966 in forum General Help and How To
    Replies: 1
    Last Post: 03-13-2014, 10:46 PM
  4. Can I use some apps on WiFi and some on my data?
    By PittsburghJake in forum Motorola Droid Ultra
    Replies: 3
    Last Post: 03-13-2014, 05:07 PM
  5. HELP Apps question
    By jfb42 in forum HTC EVO 4G LTE
    Replies: 2
    Last Post: 03-13-2014, 01:10 PM

Posting Permissions