我基本上想做以下事情:
switch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Boolean newVal = (Boolean) newValue;
if (newVal && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(getApplicationContext())) {
switch.setChecked(false);
displaySettingsDialog();
return true;
}
switch.setChecked(false);
似乎没有执行,并且在displaySettingsDialog()
发生时开关将打开。我该如何解决这个问题?