I am trying to use the Preferences api to create a settings screen for my application , I am using some EditTextPreference to change some settings but I want to send them to the server as soon as I click ok from the dialog screen , is that possible ?? how to do it please?
Note: I know how to send data to the server I just want to know where can I control the dialog pressed button.
Thanks
You can implement
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
if you first register an OnSharedPreferenceChangeListener
.
public class Prefs extends PreferenceActivity implements
OnSharedPreferenceChangeListener
@Override
protected void onPause() {
super.onPause();
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
protected void onResume() {
super.onResume();
getPreferenceScreen().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
You will find better examples if you search this site.