In my AppWidgetProvider class I have the following code inside the onUpdate()
method:
// Update each of the widgets with the remote adapter
for (int appWidgetId : appWidgetIds) {
HyperLog.i(TAG, "Updating Widget id " + appWidgetId);
...
HyperLog.i(TAG, "Starting updateAppWidget with id " + appWidgetId);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.lvActiveReminders);
appWidgetManager.updateAppWidget(appWidgetId, rv);
}
super.onUpdate(context, appWidgetManager, appWidgetIds);
But the call notifyAppWidgetViewDataChanged()
does not call the RemoteViewService Class method onDataSetChanged()
:
HyperLog.i(TAG, "onDataSetChanged is called.");
getData();
Does anyone hava a hint why it is not called?
The onUpdate() inside AppWidgetProvider is always called and the updateAppWidget refreshes the widget, but with the old data because onDataSetChaned()
is not called before.
As of the docs this is the way how we should refresh the data of the widget (Use widget collections | Android Developers).
I am testing this on an Android 12 device.