Methods Summary |
---|
static boolean | isAirplaneModeOn(android.content.Context context)
return Settings.System.getInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 0) != 0;
|
private void | onAirplaneModeChanged()Called when we've received confirmation that the airplane mode was set.
ServiceState serviceState = mPhoneStateReceiver.getServiceState();
boolean airplaneModeEnabled = serviceState.getState() == ServiceState.STATE_POWER_OFF;
mCheckBoxPref.setChecked(airplaneModeEnabled);
mCheckBoxPref.setSummary(airplaneModeEnabled ? null :
mContext.getString(R.string.airplane_mode_summary));
mCheckBoxPref.setEnabled(true);
|
public boolean | onPreferenceChange(android.preference.Preference preference, java.lang.Object newValue)Called when someone clicks on the checkbox preference.
setAirplaneModeOn((Boolean) newValue);
return true;
|
public void | pause()
mPhoneStateReceiver.unregisterIntent();
mCheckBoxPref.setOnPreferenceChangeListener(null);
|
public void | resume()
// This is the widget enabled state, not the preference toggled state
mCheckBoxPref.setEnabled(true);
mCheckBoxPref.setChecked(isAirplaneModeOn(mContext));
mPhoneStateReceiver.registerIntent();
mCheckBoxPref.setOnPreferenceChangeListener(this);
|
private void | setAirplaneModeOn(boolean enabling)
mCheckBoxPref.setEnabled(false);
mCheckBoxPref.setSummary(enabling ? R.string.airplane_mode_turning_on
: R.string.airplane_mode_turning_off);
// Change the system setting
Settings.System.putInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
enabling ? 1 : 0);
// Post the intent
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", enabling);
mContext.sendBroadcast(intent);
|