简体   繁体   中英

Android Widgets: onDataSetChanged not called by updateAppWidget()

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?

结果我需要在AppWidgetProvider.onUpdate()方法中调用AppWidgetManager.notifyAppWidgetViewDataChanged(widgetId, view)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM