Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to turn off Airplane mode
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>Not sure why the setting would show as off when it's still on?</p> <p>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:</p> <pre><code>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); </code></pre> <p>And here's the code I'm using to check the status of airplane mode - </p> <pre><code>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; } </code></pre> <p>In both cases, this.airplaneOn is a private boolean which stores the status of airplane mode.</p> <p>Could I be doing something silly here, or is checking this setting somehow unreliable?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload