• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Service implementation doubts

I'm facing a design question. I'm coding an app to read content sites( video, news, etc ). Each of these contents is handled by a specific activity. So far so good. I've find out the Service class and I will use it to monitor my internet connection implementing some methods to monitor. But because my monitoring will occurs for all activities I don't know how I can do this. If I use ServiceConnection for all activies is wrong because in the first time the connection is established. So, is it a good solution to pass the ServiceConnection object for other activies when they are created?

Thanks for replies
 
Welcome to the forums :)

You may want to use BroadcastReceiver(s) in your activities. You can set them up to receive special intents sent by your service, or register them to listen for the connection change intent that the OS sense out.

using these in your activities, you can register them in onResume() and unregister them in onPause()

this way you will have only one activity that is litening for the intent at any given time.


hope that helps
:)
 
Back
Top Bottom