0

I essentially want to do the following:

 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); does not appear to execute, and the switch will toggle on while displaySettingsDialog() happens. How do I get around this?

user2892437
  • 1,111
  • 1
  • 14
  • 22

1 Answers1

0

The solution is to return false; instead of true

user2892437
  • 1,111
  • 1
  • 14
  • 22