Ways to notify activities of download completion
My application has an IntentService which runs periodically to download data from a remote server. The download task is run inside an AsyncTask whic开发者_JS百科h has reference to Application context only.
The data downloaded is for entire application and is displayed across four different activities. When the download completes(AsyncTask completes) the service is notified of the same. Now, the service needs to notify appropriate activity to update its view. The service is not aware of which Activity of what application is in foreground.
How do I make that connection? How does the service pass a message to the activity in foreground that new data is available and it should update its views?
Please help.
Thanks.
One way is to send a broadcast, and if you have different types of activities the one that is active will receive it.
精彩评论