ahmad aghazadeh ahmad aghazadeh - 3 months ago 13
Java Question

How to get widget id another application?

Code is written as follows:

Intent widget = new Intent(
"test.widgets.Widget1x2");
widget.setAction("android.appwidget.action.APPWIDGET_UPDATE");

ComponentName name = new ComponentName(
"test.widgets", "Widget1x2");

int[] ids = AppWidgetManager.getInstance(context)
.getAppWidgetIds(name);


I have get Ids widgets application test.widgets

Answer

Use it this way:

AppWidgetManager manager = AppWidgetManager.getInstance(context);
int[] ids = manager.getAppWidgetIds(new ComponentName(context,
                Widget1x2.class));

This should work.