I have a ListView-based widget running well, and it relies on a JSON web service call to populate itself. I have a refresh button which works great, and forces a reload from the web. I do it by using a custom broadcast which then calls both onDataSetChanged(), then updateAppWidget() in sequence. What I have found is that when Android updates the widget automatically (based on the time interval set it my XML definition), only updateAppWidget() seems to be called, and my onDataSetChanged() function never runs, leading to an updated timestamp (which I update in each updateAppWidget() call), but stale data.
How can I force Android to call or trigger onDataSetChanged() at a given interval?
Turns out I needed to call AppWidgetManager.notifyAppWidgetViewDataChanged(widgetId, view)
inside my AppWidgetProvider.onUpdate()
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With