Jaa-c
Jaa-c

Reputation: 5137

How to notify objects from BroadcastReceiver

I am using AlarmManager that invokes BroadcastReceiver every 30 minutes. The receiver downloads updates from web and adds new data into the database. When this happens, I would like to notify some other objects, that the data in database changed (to drop cache, refresh GUI etc.).

Usually, I would use observer pattern for this, but since BroadcastReceiver is stateless, I can't keep track of observers between receiver invocations. I can't really find some good solution of this, what would you suggest? Maybe, there is some android specific solution to this that I didn't manage to find...

Thanks for your help!

Upvotes: 0

Views: 108

Answers (1)

Argyle
Argyle

Reputation: 3394

A BroadcastReceiver should itself do very little. Use it to fire an Intent at the Service of your choice, where all your state and resources and etc. are available to you.

Upvotes: 1

Related Questions