I have an app that has been out there on the market for months.  I
rebuilt for 1.5 a while ago and things seemed fine, but now that I
have 1.5 actually on my phone I and some of my users have noticed a
difference in the handling of preferences.

In my OnCreate() I read the preferences and register an
OnSharedPreferenceChangeListener.  Prior to 1.5, if I changed a
preference the listener worked fine and updated the preference
immediately.  After 1.5 this is no longer working.  It appears my
listener never gets called, so the new settings only apply on the next
run (i.e. the next time OnCreate gets called).  Here's a code snippet:

public void onCreate(Bundle savedInstanceState) {
    SharedPreferences settings = getSharedPreferences(PREFS_FILE, 0);
    mUseGPSAccuracy = settings.getBoolean(USE_GPS_ACCURACY, false);
        new SharedPreferences.OnSharedPreferenceChangeListener() {
            public void onSharedPreferenceChanged(SharedPreferences
sharedPreferences, String key) {
                if (key.equalsIgnoreCase(USE_GPS_ACCURACY)) {
                                        mUseGPSAccuracy = 

So in this example, a change in the USE_GPS_ACCURACY preference is
read on startup correctly, but the listener is no longer called to
change the preference while the application is running.

Does anyone have some insight as to why this has changed in 1.5 and
what the remedy is?  As I said, prior to 1.5, this code worked fine.
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to