Question

I am trying to learn list widget with the WeatherListWidget example by Google. Every other place I looked to find info on widget, they used AppWidgetProvider, but in this example they use ContentProvider. I checked to see maybe one inherets the other, so it will make sense, but they don't. I see in the manifest that ContentProvider uses the tag and AppWidgetProvider uses tag, because they inherit from different things.

So if you could just try and help me understand what makes a widget a widget. So doesn't a widget need a class that extends AppWidgetProvider?

Hope I was clear in my question... Thanks.

Was it helpful?

Solution

They are not related at all. Both are called "Providers" but they provide different things.

App widgets are always implemented by a class which extends AppWidgetProvider. Read about this class here.

Content providers do something completely different. Quoting from the official documentation:

Content providers manage access to a structured set of data.

The WeatherListWidget example uses both, but each does something different: The WeatherDataProvider is a ContentProvider which provides the weather data, and the WeatherWidgetProvider is an AppWidgetProvider which defines the widget itself:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top