开发者

Ways to notify activities of download completion

开发者 https://www.devze.com 2023-01-11 11:05 出处:网络
My application has an IntentService which runs periodically to download data from a remote server. The download task is run inside an

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消