Before we dig into the code for creating an App Widget, let's cover the basics. There are three required and one optional component:
- The AppWidgetProviderInfo file: It's an XML resource (described later)
- The AppWidgetProvider class: This is a Java class
- The View layout file: It's a standard layout XML file, with some restrictions (explained later)
- The App Widget configuration Activity (optional): This is an Activity the OS will launch when placing the widget to provide configuration options
The AppWidgetProvider must also be declared in the AndroidManifest file. Since AppWidgetProvider is a helper class based on the Broadcast Receiver, it is declared in the manifest with the <receiver> element. Here is an example ...