I need to subscribe to database changes using an Observer in an app widget. The documentation says the right place for such setup is onEnabled() in AppWidgetProvider. But, onEnabled() is only called when a new widget is added. If the app is started up and the widget is already there, it doesn’t get called and the data in the widget doesn’t update. Should I send ACTION_APPWIDGET_ENABLED broadcast on app startup or there is another way of doing this?
I need to subscribe to database changes using an Observer in an app widget.
Share
That is not possible, unless you are going to run an everlasting service, which is not a good design pattern.
If this is your own database, simply push updates to your app widget using
AppWidgetManagerwhen you change your database contents.