julius wrote: > Hi, > > I am planning to have a Service send a broadcast which a > BroadcastReceiver will act on and I would like it to create a > Notification if an application is not currently on screen, but if the > application is on screen (ie. showing to the user) then I would like > to offer a Dialog and not create the Notification. > > Is it possible to determine if an Activity or application is currently > on screen?
Why is a Service bothering sending a broadcast when it could just raise the notification or inform the activity itself? Furthermore, a BroadcastReceiver has no good way of communicating to a running activity, let alone determining if there is one there. Now, if you take the BroadcastReceiver out of the equation, your dialog-raising Activity could register itself with the service (e.g., bindService(), then call some API offered by the service). When the service wishes to notify the user, it checks to see if a listener is registered. If so, it calls a method on that listener, which triggers the activity to display the dialog. If there is no listener, the service raises the notification. Just be sure to unregister the listener as the activity exits. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 2.0 Available! -- 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

