Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find home screen widget id

Tags:

android

widget

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.

like image 995
Ran Avatar asked Mar 01 '11 22:03

Ran


People also ask

How to find widget?

On a Home screen, touch and hold an empty space. Tap Widgets .

Where is my widget drawer?

To add a widget, you first need to access the widgets drawer. On Google Pixel smartphones, this is done by tapping and holding on a blank space on your Android smartphone's Home Screen (on the wallpaper, not on the icons or on other widgets). This brings up a menu, where you need to choose Widgets.

What are widgets in android?

Widgets are an essential aspect of home screen customization. You can imagine them as "at-a-glance" views of an app's most important data and functionality that is accessible right from the user's home screen.

What is a widget app?

A widget is an extension of an application. While apps can perform many tasks, widgets generally focus on one task. For example, Android's Clock app lets you set alarms, functions as a stopwatch, manages do-not-disturb settings at bedtime, and more, while the Clock widget simply displays the time on your home screen.


1 Answers

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);
like image 198
Bartek Avatar answered Oct 02 '22 12:10

Bartek