List of usage examples for android.preference CheckBoxPreference getOnPreferenceChangeListener
public OnPreferenceChangeListener getOnPreferenceChangeListener()
From source file:com.googlecode.mindbell.MindBellPreferences.java
private void handleMuteHookOffAndStatusPermissionRequestResult(CheckBoxPreference one, int[] grantResults) { if (grantResults.length == 0) { // if request is cancelled, the result arrays are empty, so leave this option "off" and don't explain it } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // User granted the needed permission therefore this option is set to "on" if (one.getOnPreferenceChangeListener().onPreferenceChange(one, Boolean.TRUE)) { one.setChecked(true); // WARNING: This does NOT call the onPreferenceValueChangeListener }//from w w w.ja v a 2s . c o m } else if (ActivityCompat.shouldShowRequestPermissionRationale(MindBellPreferences.this, Manifest.permission.READ_PHONE_STATE)) { // User denied the needed permission and can be given an explanation, so we show an explanation new AlertDialog.Builder(MindBellPreferences.this) // .setTitle(R.string.reasonReadPhoneStateTitle) // .setMessage(R.string.reasonReadPhoneStateText) // .setPositiveButton(android.R.string.ok, null) // .create() // .show(); } else { // User denied the needed permission and checked never ask again new AlertDialog.Builder(MindBellPreferences.this) // .setTitle(R.string.neverAskAgainReadPhoneStateTitle) // .setMessage(R.string.neverAskAgainReadPhoneStateText) // .setPositiveButton(android.R.string.ok, null) // .create()// .show(); } }