Ran
Ran

Reputation: 4157

Find home screen widget id

I wrote a widget that sits on my home screen.

There is also a configuration activity which can be started from the widget or from the launcher.

When started from launcher, I don't have the widget id.

Is it possible to find it somehow?

The reason is that I want to send an update message from the activity to the widget.

Upvotes: 5

Views: 7732

Answers (1)

Bartek
Bartek

Reputation: 176

Something like this seems to work for me:

Context context = getApplicationContext();
ComponentName name = new ComponentName(context, MyWidgetProvider.class);
int [] ids = AppWidgetManager.getInstance(context).getAppWidgetIds(name);

Upvotes: 16

Related Questions