Shakeeb Ayaz
Shakeeb Ayaz

Reputation: 6096

How to get widgetID and ComponentName of my application in service

I am updating the widget from service(srvice and widget class are in two different package) like this

AppWidgetManager widgetManager = AppWidgetManager.getInstance(this);
ComponentName widgetComponent = new ComponentName(this,MyWidgetProvider.class);
int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
Intent update = new Intent();
update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
 update.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
sendBroadcast(update);

it updates my widget but the problem is that it also updating other widgets of the device too because of which my widget updates after all the widget gets updated.

So now I want to update only my widget how can i do that

Upvotes: 2

Views: 2870

Answers (1)

Jans
Jans

Reputation: 11250

According Android documentation getAppWidgetIds return a list of id that have been bound to specific WidgetProvider, that is all your widget instance id not id of widgets under other WidgetProvider.

Upvotes: 1

Related Questions