The most important
AppWidgetProvider callback is
onUpdate(). It is called everytime an appwidget is added.
onAppWidgetOptionsChanged() is called when the widget is placed or resized.
onDeleted(Context, int) is called when the widget is deleted.
Latest Android Studio will create & integrate a Basic Widget to your Application in 2 steps.
Right on your Application ==> New ==> Widget ==> App Widget
It will show a Screen like below & fill the fields
It will create & integrate a basic HelloWorld Widget(Including Layout File , Meta Data File , Declaration in Manifest File etc.) to your Application.
Manifest Declaration -
AppWidgetProvider class in your application's
AndroidManifest.xml file. For example:
Add the AppWidgetProviderInfo metadata in
- Declare two receivers in a manifest file:
- Create two layouts
- Declare the subclass
UVMateWidget2x2 from the
UVMateWidget class with extended behavior:
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0