How to open AlertDialog from preference screen?

android, android-preferences

Solution

Override `onSharedPreferenceChanged` in your `PreferenceActivity` class:

public class MyPreferences extends PreferenceActivity implements OnSharedPreferenceChangeListener {
    ...
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if (key.equals("MyCheckboxPreferenceKey")) {
            //Show your AlertDialog here!
        }
    }

Problem

I am developing Application in android I want to show AlertDialog if user check the checkboxpreference from preference screen. so how i can do that..?

Original source

Related problems