@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { sharedPreferences.edit().commit(); if (keys.contains(key)) return; if (!sharedPreferences.getBoolean("dontshowkilldialog", false) && !alertShown) { LayoutInflater adbInflater = LayoutInflater.from(mContext); View dontShowAgainLayout = adbInflater.inflate(R.layout.dialog_with_checkbox, null); ((TextView) dontShowAgainLayout.findViewById(R.id.message)) .setText(R.string.alert_autokill_summary); final CheckBox dontShowAgain = (CheckBox) dontShowAgainLayout.findViewById(R.id.skip); dontShowAgain.setIncludeFontPadding(false); dontShowAgain.setText(R.string.alert_autokill_checkbox); new MaterialDialog.Builder(mActivity) .theme(Theme.DARK) .customView(dontShowAgainLayout, true) .cancelable(false) .title(R.string.alert_autokill_title) .positiveText(R.string.alert_autokill_ok) .negativeText(R.string.alert_autokill_cancel) .callback( new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog materialDialog) { if (dontShowAgain.isChecked()) { SharedPreferences settings = mContext.getSharedPreferences( Common.PREFERENCES_NAME, Context.MODE_WORLD_READABLE); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("dontshowkilldialog", true).commit(); editor.putBoolean("autokilllauncher", true).commit(); } alertAnswerKill = true; CommonUI.restartLauncher(false); } @Override public void onNegative(MaterialDialog materialDialog) { if (dontShowAgain.isChecked()) { SharedPreferences settings = mContext.getSharedPreferences( Common.PREFERENCES_NAME, Context.MODE_WORLD_READABLE); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("dontshowkilldialog", true).commit(); editor.putBoolean("autokilllauncher", false).commit(); } materialDialog.dismiss(); } }) .build() .show(); alertShown = true; } if (sharedPreferences.getBoolean("autokilllauncher", false) || alertAnswerKill) { CommonUI.restartLauncher(false); } }