Wednesday, September 7, 2011

[android-developers] Re: Honeycomb -- Activity.getIntent().getExtras().getString() encountering race condition?

I noticed I forgot to mention, I do not actually use those lines of
code for anything, I just placed them ahead of the original code
because I had a hunch about it being a race condition...
I never use that String, I left the original code in place.... :D

Peace,
Dan

On Sep 7, 9:58 am, IcedNet <d...@icednet.info> wrote:
> Yet, the three lines of code alleviates the issue on every run
> (Keeping that build around for the eventual Log.wtf factor)
> :)
>
> Thanks for the input, Mark, and keep those eBooks coming, man,
> priceless!
>
> Peace,
> Dan
>
> On Sep 6, 10:04 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
>
>
>
>
>
>
> > On Tue, Sep 6, 2011 at 9:57 PM, IcedNet <d...@icednet.info> wrote:
> > > Activity two starts and calls an internal AsyncTask which uses
> > > `Activity.this.getIntent().getExtras().getString(<key>)` as a
> > > parameter for an object
>
> > Grab this value in the AsyncTask constructor or onPreExecute(). Do not
> > refer to an Activity in doInBackground(), as with configuration
> > changes, it might not be the right activity anymore.
>
> > > I decided to place those three lines of code in onCreate and use a
> > > String field instead of accessing the Activity's Intent within
> > > doInBackground and have yet to encounter the issue since doing so.
>
> > Sounds like a plan.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > _The Busy Coder's Guide to Android Development_ Version 3.6 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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment