Code example for CheckBoxPreference

Methods: setOnPreferenceChangeListener

0
                mAirplaneModeObserver);
    } 
     
    public void pause() { 
        mPhoneStateReceiver.unregisterIntent();
        mCheckBoxPref.setOnPreferenceChangeListener(null);
        mContext.getContentResolver().unregisterContentObserver(mAirplaneModeObserver);
    } 
 
    public static boolean isAirplaneModeOn(Context context) {
        return Settings.Global.getInt(context.getContentResolver(),
                Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
    } 
 
    private void setAirplaneModeOn(boolean enabling) {
        // Change the system setting 
        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 
                                enabling ? 1 : 0);
        // Update the UI to reflect system setting 
        mCheckBoxPref.setChecked(enabling);