I have
public class Preferences extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
Before the preferences are left I want to do a sanity check. I can do that in activity which calls the preference activity during the onAcitivtyResult()
method. But that means if I have to tell the user to correct the preferences I have to call the preference activity again which I want to avoid. Is there some way that I can do a check before I leave this preference activity? Something that the user can only leave the preference activity when the sanity check is ok. I guess I have to override the back button, do I?
Thanks.
You could use http://developer.android.com/reference/android/preference/Preference.OnPreferenceChangeListener.html to get notified right when a certain preference has been set. From there, you could react accordingly.