On Wed, Jan 25, 2012 at 8:19 AM, elDoudou <the.edouard.merc...@gmail.com> wrote:
> As soon as a background thread attempts to invoke
> the "Fragment.getString(int resId)" while the fragment is not attached
> to its view, the caller thread gets an "IllegalStateException" with a
> message of the form "Fragment MyfragmentClass{XXXXX} not attached to
> Activity".

Never refer to a fragment or an activity from a background thread. For
example, if you use AsyncTask, pass your string into the task's
constructor or execute() method.

> Did someone solve this problem of detached thread
> accessing the i18n in an elegant and efficient way?

Yes, you pass the data into the thread.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 3.7 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