0

我基本上想做以下事情:

 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()发生时开关将打开。我该如何解决这个问题?

4

1 回答 1

0

解决方案是return false;代替true

于 2017-01-20T20:44:06.093 回答