Simple Widget App

This simple application shows how to setup a Home screen widget using a simple hello world like host application. The widget will display the default application icon with a clickable button next to it. When the button is pressed, the host application will be launched and a greeting appears.

There are four things that we must do to create a widget.

  1. Create a layout resource that defines the UI for our widget.

  2. Create an XML file that describes the metadata of our widget.

  3. Create an Intent Receiver or AppWidgetProvider that maintains and controls our widget

  4. Declare your application widget in the application manifest.

Click here to download the source file. Steps 1, 2, and 4 are already implemented. You will implement step 3. First we will take a look at steps 1 and 2.

Step 1: Create a layout resource that defines the UI for our widget

Step 2: Create an XML file that describes the metadata of our widget.

Step 3: Create an Intent Receiver or AppWidgetProvider that maintains and controls our widget.

Step 4: Declare your application widget in the application manifest.

Run the application in the emulator and add the widget to your home screen.

If you look further in the src folder, you’ll notice the SimpleWidget.java file. This Activity class does nothing and is essentially the entry point into your application. Feel free to tinker around with it as well as the layout and interfaces of the Widget.

For more information on Widgets, check out the Android developers guide on it.

Android Developers: App Widgets

Also check out the Widget design Guidelines.

Android Developers: Widget Design Guidelines