I suggest you to try the code pasted below:
ComponentName component=new ComponentName(context,WidgetTaskSchedular.class);
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.listWidget);
appWidgetManager.updateAppWidget(component, remoteView);
notifyAppWidgetViewDataChanged()
--->Notifies the specified collection view in all the specified AppWidget
instances to invalidate their currently data.
So 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/network related operations, data fetching operation from database and other operations in onDataSetChanged()
, get the response and add it to your data-set which maybe ArrayList
or any such Collection
.
You can refer Using App Widgets with Collections