I googled and found the code to manipulate listview data using RemoteViewsService and RemoteViewsService.RemoteViewsFactory. as below
You can update the ListView by using notifyAppWidgetViewDataChanged() method of AppWidgetManager. You will have to get the instance of AppWidgetManager, get the AppWidgetIds and the call appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, viewId);
Pseudo Code,
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
int appWidgetIds[] = appWidgetManager.getAppWidgetIds(
new ComponentName(context, WidgetProvider.class));
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.listview);
When you call notifyAppWidgetViewDataChanged()
then the onDataSetChanged()
method of RemoteViewsFactory
will be called which is serving as a Adapter for your ListView. You can do web-service stuff and other operations in onDataSetChanged()
, get the response and add it to your data-set which maybe ArrayList or any such Collection.
For further readings/reference you can check Keeping Collection Data Fresh part from the docs. Also you can check a demo example from my github.