How can an Android Service know that its not bound to any Activities
Posted
by tunneling
on Stack Overflow
See other posts from Stack Overflow
or by tunneling
Published on 2010-06-05T14:48:18Z
Indexed on
2010/06/05
14:52 UTC
Read the original article
Hit count: 201
I have an Android Service that I would like to keep running even after the last Activity has been popped off the stack, or the User has chosen to do something else.
Essentially the Service is listening for changes on a remote server, and I would like to generate a Notification if and only if an Activity from the app isn't running(or visible). In other words, I don't want the Notifications to occur while the User is directly interacting with the app.
In the case where the User is directly interacting with the app, the Service will notify the Activity and update appropriate UI elements based on the changes. I plan to implement this through the Observer pattern.
How can the Service know if none of apps Activities are bound to it?
Thanks, J
© Stack Overflow or respective owner