MobileCreating a Home Screen App Widget on Android

Creating a Home Screen App Widget on Android

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Android users got their first taste of the App Widget when some basic controls like the Clock and Picture Frame Home Screen controls shipped with the first Android handsets. However, the App Widget API was not publicly available for developers to use until recently. This interface gives developers two new and interesting ways to provide Android application functionality outside the traditional boundaries of a phone application. Developers can use the App Widget API (released in Android 1.5) to create simple controls and craft new App Widget hosts to display and use these controls.

This article shows you how to create a Home Screen App Widget that updates at a user-configured time interval by using the AlarmManager interface. Specifically, you will see how to create an App Widget that displays an image chosen randomly from a set of images. The displayed image changes periodically according to a timing interval configured by the user.

Creating a simple App Widget involves several steps:

  1. Create a RemoteView, which provides the user interface for the App Widget.
  2. Tie the RemoteView to an Activity that implements the AppWidgetProvider interface.
  3. Provide key App Widget configuration information in the Android manifest file.

 

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories