Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:16:38+00:00 2026-06-05T13:16:38+00:00

I’ve create an app with a button that allows airplane mode to be toggled

  • 0

I’ve create an app with a button that allows airplane mode to be toggled on and off. Works fine when turning airplane mode on. But strangely, airplane mode seems to stay on when it is toggled off.

If I check the phone settings after I turn it off, they indicate that airplane mode is off. But the airplane mode icon still shows in the top bar of the phone, and holding down the phone’s power button shows that airplane mode is still on.

Not sure why the setting would show as off when it’s still on?

Here is the code I’m using to turn it off – I’ve debugged and it’s definitely hitting this. mContext is a variable I’m using to hold the context, this is passed into a settings class which then has methods in for turning airplane mode off and on:

System.putInt(mContext.getContentResolver(),
android.provider.Settings.System.AIRPLANE_MODE_ON, 0);
this.airplaneOn = false;
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", 0);
mContext.sendBroadcast(intent);

And here’s the code I’m using to check the status of airplane mode –

public boolean isAirplaneOn() {
  int airplaneMode = 0;
  try {
    airplaneMode = System.getInt(mContext.getContentResolver(),
  android.provider.Settings.System.AIRPLANE_MODE_ON);
    } catch (SettingNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if (airplaneMode == 1) {
        this.airplaneOn = true;
    } else {
        this.airplaneOn = false;
    }
    return airplaneOn;
}

In both cases, this.airplaneOn is a private boolean which stores the status of airplane mode.

Could I be doing something silly here, or is checking this setting somehow unreliable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:16:39+00:00Added an answer on June 5, 2026 at 1:16 pm

    I’ve had success doing the following code:

    public static boolean isFlightModeEnabled(Context context) {
        return Settings.System.getInt(context.getContentResolver(),
            Settings.System.AIRPLANE_MODE_ON, 0) == 1;
    }
    
    public static void toggleFlightMode(Context context) {
        boolean isEnabled = isFlightModeEnabled(context);
    
        Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
    
        Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        intent.putExtra("state", !isEnabled);
        context.sendBroadcast(intent);
    }
    

    The only difference I see between my code and yours is that in your putInt() you have hard-coded 0.

    One other thing to be aware of is according to the docs, ACTION_AIRPLANE_MODE_CHANGED is

    This is a protected intent that can only be sent by the system.

    I haven’t had issues with this in the past, but perhaps your device is newer and enforcing something that the older phones I’ve had success with don’t enforce.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.