Wednesday, June 8, 2011

Re: [android-developers] Re: Broadcasting custom intent actions to background activities from foreground activity.

On Wed, Jun 8, 2011 at 4:16 PM, Diego Tori
<diegotoridoesandroid@gmail.com> wrote:
> That's the thing, if I set a shared preference flag or cached flag via
> cache object, and they did try to check for that value in onResume,
> wouldn't the first activity from the back stack to get the foreground
> check its state, then set it back to false after checking for it being
> true before having to do work?

Delete the flag. You don't need the flag. Update the UI of the
activity in onResume(). Period.

> Even if I didn't reset the flag, every
> time it would hit that function, it would still get caught in that
> flag, so that isn't really useful.

Hence, get rid of the flag. Update the UI of the activity in onResume(). Period.

> So there is no way that I can just
> broadcast one intent that my listening activities can listen to after
> the intent is sent as soon as they get the foreground again?

What makes you think that your activity even exists? Your
non-foreground activities may not even be in memory, because Android
may have destroyed them to save RAM.

If you simply update your UI in onResume(), it handles both the
activity-in-RAM and the activity-out-of-RAM scenario.

Your proposed model is akin to: every time Google indexes a new page,
it proactively updates every browser on the face of the planet, even
those that do not use Google, do not care about the newly indexed
page, or are not even running.

> Keep in mind that this is not a one-time event.

All the more reason to not push updates out to activities that do not
yet need the information.

> Rather it is an event
> that the user generates, all I want those other activities to know is
> whether or not the event was generated by the user while in the
> background.

So, update the UI of the activity from your persistent store or
in-memory cache in onResume(). Period.

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

Android 3.0 Programming Books: http://commonsware.com/books

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate