简体   繁体   English

Android Widgets:updateAppWidget()未调用onDataSetChanged

[英]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. 我有一个基于ListView的小部件运行良好,它依赖于JSON Web服务调用来填充自己。 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. 我通过使用自定义广播来执行此操作,然后调用onDataSetChanged(),然后按顺序调用updateAppWidget()。 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. 我发现当Android自动更新窗口小部件时(基于设置我的XML定义的时间间隔),似乎只调用了updateAppWidget(),并且我的onDataSetChanged()函数从不运行,导致更新的时间戳(我在每个updateAppWidget()调用中更新,但是陈旧的数据。

How can I force Android to call or trigger onDataSetChanged() at a given interval? 如何强制Android以给定的间隔调用或触发onDataSetChanged()?

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android updateAppWidget 被调用但没有更新小部件或到达 RemoteViewsFactory? - Android updateAppWidget is called but not updating the widget or reaching RemoteViewsFactory? Android-AppWidget AppWidgetManager.updateAppWidget()不会立即被调用 - Android - AppWidget AppWidgetManager.updateAppWidget() not being called instantly 在 notifyAppWidgetViewDataChanged 后未调用 RemoteViewService 中的 onDataSetChanged() - onDataSetChanged() in RemoteViewService is not called after notifyAppWidgetViewDataChanged 调用notifyAppWidgetViewDataChanged后,在RemoteViewsFactory中不调用onDataSetChanged - onDataSetChanged is not called in RemoteViewsFactory after notifyAppWidgetViewDataChanged is called 更新AppWidget后未调用RemoteViewsFactory上的onDataSetChanged() - onDataSetChanged() on RemoteViewsFactory not being called after updating AppWidget Android updateAppWidget不会更新 - Android updateAppWidget doesn't update AppWidgetManager.updateAppWidget中的android.os.TransactionTooLargeException - android.os.TransactionTooLargeException in AppWidgetManager.updateAppWidget Android Widget 显示错误和 updateAppWidget 找不到任何视图 - Android Widget displays error and updateAppWidget couldn't find any view Android适配器在onDataSetChanged有时间处理数据之前格式化布局 - Android Adapter formats layout before onDataSetChanged has had time to process the data 当onDatasetChanged方法包含异步网络调用Android时,Widget ListView不会刷新 - Widget ListView not refreshing when onDatasetChanged method contains async network call Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM