Reputation: 326
From the docs:
AppWidgetManager.getAppWidgetIds(ComponentName provider) Get the list of appWidgetIds that have been bound to the given AppWidget provider.
This returns a list of widget ids including widgets that have been deleted from the homescreen. Is there a way besides tracking the add/delete events and mainlining my own list to retrieve this information?
Upvotes: 1
Views: 408
Reputation: 7592
Here is a bit of my code which works if you still need this.
private void updateWidget() {
// We want to make sure the widget is always up to date.
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this.getApplicationContext());
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(this, Widget.class));
if(appWidgetIds.length > 0) {
new Widget().onUpdate(this, appWidgetManager, appWidgetIds);
}
}
You Can see there how I am able to get all the id's I need. Then here I update my widget from an activity.
Upvotes: 2