title: ListPreference onClickListener takes twice to execute
body: <p>So I'm having this problem where my ListPreference takes two clicks upon it, to actually do what's in the onClick listener. Here's my code</p>
  
  <pre><code>@Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
      final ListPreference prefListThemes = (ListPreference) findPreference("prefMaterialThemes");
      prefListThemes.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
              Toast.makeText(getApplicationContext(), "test", Toast.LENGTH_SHORT).show();
              System.out.println("Test prntln");
              // Restart Activity to apply Theme
              Intent intent = new Intent(getApplicationContext(), MainActivity.class);
              intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
              startActivity(intent);
              return false;
          }
      });
  </code></pre>
  
  <p>As you can see what I'm trying to do is just a simple restart of the app to apply my theme. At first I thought it might be that intent code causing the problem, but even when I have just a toast in that onclick listener you still have to click the list preference, select an option, then click the preference again, and select the option once more for it to actually do anything. If you could help that would be great. Thank You!</p>
  
  <p>SettingsActivity which gets the preferences from preferences.xml</p>
  
  <pre><code>import android.content.Context;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.preference.CheckBoxPreference;
  import android.preference.EditTextPreference;
  import android.preference.ListPreference;
  import android.preference.Preference;
  import android.preference.PreferenceActivity;
  import android.preference.PreferenceManager;
  import android.support.v4.content.IntentCompat;
  import android.widget.Toast;
  
  import com.iliakplv.notes.R;
  import com.iliakplv.notes.gui.main.LauncherActivity;
  import com.iliakplv.notes.gui.main.MainActivity;
  
  import java.util.List;
  
  public class SettingsActivity extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
  
      private static final int PREFERENCES = R.xml.preferences;
  
      private final static String PREFS_LIST_OF_THEMES = "prefMaterialThemes";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //noinspection deprecation
          addPreferencesFromResource(PREFERENCES);
          PreferenceManager.setDefaultValues(this, PREFERENCES, false);
  
          // These 3 lines are required for the onSharedPreferenceChanged method
          Context context = getApplicationContext();
          SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
          settings.registerOnSharedPreferenceChangeListener(this);
          // End
      }
  
      @Override
      public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
  
          final CheckBoxPreference prefDarkThemeCB = (CheckBoxPreference) findPreference("prefDarkTheme");
          prefDarkThemeCB.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
              @Override
              public boolean onPreferenceClick(Preference preference) {
                  if (prefDarkThemeCB.isChecked()) {
                      // Restart Activity to apply Theme
                      Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                      startActivity(intent);
                  } else if (prefDarkThemeCB.isChecked() == false) {
                      // Also restart activity to apply default theme
                      Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                      startActivity(intent);
                  }
                  return false;
              }
          });
  
          final ListPreference prefListThemes = (ListPreference) findPreference("prefMaterialThemes");
          prefListThemes.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
              public boolean onPreferenceChange(Preference preference, Object newValue) {
                  Toast.makeText(getApplicationContext(), "toast", Toast.LENGTH_SHORT).show();
                  System.out.println("Toasted");
                  // Restart Activity to apply Theme
                  Intent intent = new Intent(getApplicationContext(), MainActivity.class);
                  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
                  startActivity(intent);
                  return false;
              }
          });
  
          final CheckBoxPreference prefRequirePasswordCB = (CheckBoxPreference) findPreference("prefEnablePasswordLock");
          prefRequirePasswordCB.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
              @Override
              public boolean onPreferenceClick(Preference preference) {
                  if (prefRequirePasswordCB.isChecked()) {
                      EditTextPreference prefUsersPass = (EditTextPreference) findPreference("prefPassword");
                      // Check to see if the users password is empty before allowing them to check the require password box
                      if (prefUsersPass.getText().toString().isEmpty()) {
                          prefRequirePasswordCB.setChecked(false);
                          Toast.makeText(getApplicationContext(), R.string.password_required, Toast.LENGTH_SHORT).show();
                          //System.out.println("Empty password");
                      } else if (prefUsersPass.getText().toString().trim().length() == 0) {
                          // The above line checks to see if the User's pass is all spaces :p
                          prefRequirePasswordCB.setChecked(false);
                          Toast.makeText(getApplicationContext(), R.string.password_required, Toast.LENGTH_SHORT).show();
                          //System.out.println("Trimmed the password because they used all spaces probably and still empty");
                      } else {
                          Toast.makeText(getApplicationContext(), R.string.password_has_been_set, Toast.LENGTH_SHORT).show();
                          //System.out.println("kapow! they have a password and its: " + prefUsersPass.getText().toString());
                      }
                  }
                  return false;
              }
          });
  
      }
  
  }
  </code></pre>
  
  <p>Preferences.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;PreferenceCategory android:title="@string/security_pref_category"&gt;
          &lt;CheckBoxPreference
              android:defaultValue="false"
              android:key="prefEnablePasswordLock"
              android:summary="@string/pref_require_password_for_app_description"
              android:title="@string/pref_require_password_for_app" /&gt;
          &lt;EditTextPreference
              android:defaultValue=""
              android:key="prefPassword"
              android:summary="@string/pref_password_description"
              android:title="@string/pref_password_title" /&gt;
      &lt;/PreferenceCategory&gt;
  
  
      &lt;PreferenceCategory android:title="@string/look_and_feel_pref_category"&gt;
          &lt;CheckBoxPreference
              android:defaultValue="false"
              android:key="prefDarkTheme"
              android:summary="@string/pref_dark_theme_description"
              android:title="@string/pref_dark_theme" /&gt;
  
          &lt;ListPreference
              android:defaultValue="1"
              android:entries="@array/pref_app_themes"
              android:entryValues="@array/pref_app_theme_values"
              android:key="prefMaterialThemes"
              android:summary="@string/pref_change_theme_description"
              android:title="@string/pref_change_theme" /&gt;
  
  
      &lt;/PreferenceCategory&gt;
  
      &lt;PreferenceCategory android:title="@string/misc_pref_category"&gt;
          &lt;CheckBoxPreference
              android:defaultValue="true"
              android:key="linkify_note_text"
              android:summary="@string/settings_linkify_subtitle"
              android:title="@string/settings_linkify_title" /&gt;
  
          &lt;Preference
              android:key="contactDevKey"
              android:summary="@string/pref_contact_developer_description"
              android:title="@string/pref_contact_developer"&gt;
              &lt;intent
                  android:action="android.intent.action.VIEW"
                  android:data="mailto:support@oxpheen.com?subject=Support *Notes"&gt;
                  &lt;extra
                      android:name="android.intent.extra.TEXT"
                      android:value="" /&gt;
                  &lt;!-- Value is whats in the body, blank for now --&gt;
              &lt;/intent&gt;
          &lt;/Preference&gt;
  
      &lt;/PreferenceCategory&gt;
  
  
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>Arrays.xml (used in the preference.xml file to get the entries for the list preference)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
  
      &lt;string-array name="pref_app_themes"&gt;
          &lt;item name="1"&gt;Default&lt;/item&gt;
          &lt;item name="2"&gt;Dark&lt;/item&gt;
          &lt;item name="3"&gt;AMOLED&lt;/item&gt;
          &lt;item name="4"&gt;Red&lt;/item&gt;
          &lt;item name="5"&gt;Pink&lt;/item&gt;
          &lt;item name="6"&gt;Purple&lt;/item&gt;
          &lt;item name="7"&gt;Deep Purple&lt;/item&gt;
          &lt;item name="8"&gt;Blue&lt;/item&gt;
          &lt;item name="9"&gt;Light Blue&lt;/item&gt;
          &lt;item name="10"&gt;Cyan&lt;/item&gt;
          &lt;item name="11"&gt;Teal&lt;/item&gt;
          &lt;item name="12"&gt;Green&lt;/item&gt;
          &lt;item name="13"&gt;Light Green&lt;/item&gt;
          &lt;item name="14"&gt;Lime&lt;/item&gt;
          &lt;item name="15"&gt;Yellow&lt;/item&gt;
          &lt;item name="16"&gt;Amber&lt;/item&gt;
          &lt;item name="17"&gt;Orange&lt;/item&gt;
          &lt;item name="18"&gt;Deep Orange&lt;/item&gt;
          &lt;item name="19"&gt;Brown&lt;/item&gt;
          &lt;item name="20"&gt;Grey&lt;/item&gt;
          &lt;item name="21"&gt;Blue Grey&lt;/item&gt;
  
      &lt;/string-array&gt;
      &lt;string-array name="pref_app_theme_values"&gt;
          &lt;item name="1"&gt;1&lt;/item&gt;
          &lt;item name="2"&gt;2&lt;/item&gt;
          &lt;item name="3"&gt;3&lt;/item&gt;
          &lt;item name="4"&gt;4&lt;/item&gt;
          &lt;item name="5"&gt;5&lt;/item&gt;
          &lt;item name="6"&gt;6&lt;/item&gt;
          &lt;item name="7"&gt;7&lt;/item&gt;
          &lt;item name="8"&gt;8&lt;/item&gt;
          &lt;item name="9"&gt;9&lt;/item&gt;
          &lt;item name="10"&gt;10&lt;/item&gt;
          &lt;item name="11"&gt;11&lt;/item&gt;
          &lt;item name="12"&gt;12&lt;/item&gt;
          &lt;item name="13"&gt;13&lt;/item&gt;
          &lt;item name="14"&gt;14&lt;/item&gt;
          &lt;item name="15"&gt;15&lt;/item&gt;
          &lt;item name="16"&gt;16&lt;/item&gt;
          &lt;item name="17"&gt;17&lt;/item&gt;
          &lt;item name="18"&gt;18&lt;/item&gt;
          &lt;item name="19"&gt;19&lt;/item&gt;
          &lt;item name="20"&gt;20&lt;/item&gt;
          &lt;item name="21"&gt;21&lt;/item&gt;
      &lt;/string-array&gt;
  
  &lt;/resources&gt;
  </code></pre>