Find the id of the home screen widget

I wrote a widget that sits on my home screen.

There is also configuration activity that can be launched from the widget or from the launchpad.

When you start from start, I don't have the widget id.

Is there any way to find this?

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

+3
source share
1 answer

It seems to me that something like this works:

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

Source: https://habr.com/ru/post/1795621/


All Articles