Thx! You gave me the hint to check the code and If my understanding is
right the implementation (editor.commit()) has changed between 2.2 and
2.3 (2.3 runs in the main thread, 2.2 doesn't have this feature). It
would be interesting to see the API documentation for 2.2

best regards,

On May 6, 9:41 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> Based on the source code, unless you have done some fairly strange
> things involving Loopers, onSharedPreferenceChanged() is called on the
> main application thread.
>
>
>
>
>
>
>
>
>
> On Fri, May 6, 2011 at 4:44 AM, laborg <gerhard.aig...@gmail.com> wrote:
> > Hi!
>
> > The API (http://developer.android.com/reference/android/content/
> > SharedPreferences.OnSharedPreferenceChangeListener.html) states that
> > onSharedPreferenceChanged is run on "your main thread". With this
> > believe I implemented a activity which is registered as a
> > SharedPreferenceListener within onStart and unregistered in onStop.
> > When a broadcast receiver changes the sharedPreference of interest I
> > receive an exception
> > "android.view.ViewRoot$CalledFromWrongThreadException: Only the
> > original thread that created a view hierarchy can touch its views."
>
> > Why is this? I'm aware of the fact to use handlers for this kind of
> > problem but is the API wrong or do I misinterpret the writing "your
> > main thread" ? I read it as: "Since it's on the main thread you don't
> > have to worry..."
>
> > best reagards,
> > Gerhard
>
> > --
> > 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
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 3.4 Available!

-- 
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