Hi,
First, I'm new in the Android application development world.
I have a background service application that get informations through a web service. This service has to alert the user when it gets some abnormal values. I also have a UI application that is used to display these informations. Finally, the only way I found to be able to get the service and the UI application to share these informations, was to create a third application that defines a custom ContentProvider . I've tried to define the ContentProvider in the service application to have only two applications, but it didn't worked. Everything is fine with three applications. If you have a better solution, please let me know!
For CPU and battery saving reasons, the background service is refreshing the informations each 5 minutes. But, the UI application needs to refresh faster than 5 minutes. So, when the UI application starts, I need it to notify the background service to start refreshing at a much faster rate. And, obviously, when it closes, the background service needs to get back to the normal refresh rate.
My problem is that I don't know how to notify the background service from the UI application. I can set a field in the database when the UI application opens and closes, and check that field every second in the background service, but it will kill the CPU and the battery! How can I set some listener in the background service and send and event in the UI application. Can I define custom Broadcast events?
Sorry for my bad english. Thanks for your help .
First, I'm new in the Android application development world.
I have a background service application that get informations through a web service. This service has to alert the user when it gets some abnormal values. I also have a UI application that is used to display these informations. Finally, the only way I found to be able to get the service and the UI application to share these informations, was to create a third application that defines a custom ContentProvider . I've tried to define the ContentProvider in the service application to have only two applications, but it didn't worked. Everything is fine with three applications. If you have a better solution, please let me know!
For CPU and battery saving reasons, the background service is refreshing the informations each 5 minutes. But, the UI application needs to refresh faster than 5 minutes. So, when the UI application starts, I need it to notify the background service to start refreshing at a much faster rate. And, obviously, when it closes, the background service needs to get back to the normal refresh rate.
My problem is that I don't know how to notify the background service from the UI application. I can set a field in the database when the UI application opens and closes, and check that field every second in the background service, but it will kill the CPU and the battery! How can I set some listener in the background service and send and event in the UI application. Can I define custom Broadcast events?
Sorry for my bad english. Thanks for your help .