Prevent dialog from showing in EditTextPreference onClick

758 views Asked by At

I want to show the system dialog from which the user can pick his google account, and I want it to show when the user click in an EditTextPreference. The problem is that the "normal" dialog keep showing before the system default one.

Here is the code.

public static class SettingsFragment extends PreferenceFragment {

    Preference googleMail;
    Intent intent = AccountPicker.newChooseAccountIntent(null, null,
            new String[]{GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE},
            true, null, null, null, null);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Load the preferences from an XML resource
        PreferenceCategory fakeHeader;

        // Add 'fake' preferences.
        addPreferencesFromResource(R.xml.pref_fake);

        fakeHeader = new PreferenceCategory(getActivity().getBaseContext());
        fakeHeader.setTitle(R.string.pref_header_calendar);
        getPreferenceScreen().addPreference(fakeHeader);
        addPreferencesFromResource(R.xml.pref_calendar);

        bindPreferenceSummaryToValue(findPreference("pref_googleMail"));

        googleMail = findPreference("pref_googleMail");
        googleMail.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                startActivityForResult(intent, ACCOUNT_PICKED);

                return false;
            }
        });
    }
}
1

There are 1 answers

0
Numi On

You should change your EditTextPreference to plain Preference. After this basic dialog is not shown.