I tried implementing OnSharedPreferenceChangeListener as well (1.5_r2)
and could not get it to work. Since I never had working code in a
prior Android version, this could be due to a mistake in my coding.
However, I just switched to using onPreferenceChangeListener() and it
worked fine...

Jim


On Jun 22, 10:55 pm, Dave <srandls...@gmail.com> wrote:
> 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 apreferencethe 
> listener worked fine and updated thepreference
> 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);
>     ....
>     settings.registerOnSharedPreferenceChangeListener(
>         new SharedPreferences.OnSharedPreferenceChangeListener() {
>             public void onSharedPreferenceChanged(SharedPreferences
> sharedPreferences, String key) {
>                 if (key.equalsIgnoreCase(USE_GPS_ACCURACY)) {
>                                         mUseGPSAccuracy = 
> sharedPreferences.getBoolean(USE_GPS_ACCURACY,
> false);
>                 }
>             }
>         });
>
> So in this example, a change in the USE_GPS_ACCURACYpreferenceis
> read on startup correctly, but the listener is no longer called to
> change thepreferencewhile 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.
> Thanks
--~--~---------~--~----~------------~-------~--~----~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to