A variation on that theme is to use an ordered broadcast, so it can be picked up by a foreground activity (if one exists) or raise a Notification (if not):
http://commonsware.com/blog/2010/08/11/activity-notification-ordered-broadcast.html https://github.com/commonsguy/cw-advandroid/tree/master/Broadcast/Ordered (and, yes, a year-and-a-half later, I am finally getting this topic into one of my books...) On Thu, Feb 16, 2012 at 1:48 AM, Kristopher Micinski <[email protected]> wrote: > It seems like what you should really be doing is using a system > notification anyway, you don't want to randomly pop up a dialog box > (actually, you can probably pop up a toast in your case, which you can > do from the application context..), but a system bar notification > probably makes the most sense. > > kris > > On Thu, Feb 16, 2012 at 1:28 AM, Weston Weems <[email protected]> wrote: >> Treking >> >> Basically this is what I've done... say I have MyAppActivity which has >> stuff that automatically registers itself into application... events >> come in, application gets last accessed and I use that to start >> dialogs etc. >> >> Seemed like there were cases where it was throwing exceptions about >> null window token even though the activity reference itself wasnt >> null. Ie, just simply keeping a reference around doesnt guarentee its >> suitable to spawn dialogs (even if it IS an activity). >> >> I also tried to have in my base callback a context we pass through... >> could be activity or app context and thats fine... and say I want to >> spawn dialog if context is a subclass of Activity... seems like that >> works decent... but seems like that has potential to have problems if >> the activity goes away before the callback returns. >> >> I guess I am frustrated... I like in IOS dev I can just create a >> UIAlert, and show =) >> >> I know that there are things in place on purpose (for fluid user >> experience, but for a lot of the stuff I build, its much lower >> level... rom hacking and such and I do have a legitimate excuse to be >> wanting to do things the way I want) >> >> Weston >> >> >> >> On Feb 15, 4:12 pm, TreKing <[email protected]> wrote: >>> On Wed, Feb 15, 2012 at 5:49 PM, Weston Weems <[email protected]> wrote: >>> > it doesnt even seem there is a decent way to >>> > test to see if context is >>> > 1) a valid ui context from which I can pop dialogs, show dialog fragments >>> > etc >>> >>> Don't use a base Context, use an Activity, which itself is a Context, but >>> one associated with UI (as opposed to, say, a Service). >>> >>> > 2) know if the reference to the instance of the activity or whatever >>> > actually has ties enough to spawn a dialog etc. >>> >>> That is not very clear. >>> >>> --------------------------------------------------------------------------- >>> ---------------------- >>> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago >>> transit tracking app for Android-powered devices >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > 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/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Warescription: Three Android Books, Plus Updates, One Low Price! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

