Defining Your Widget Settings

Widget definition resources are stored as XML in the res/xml folder of your project. The appwidget-provider tag lets you describe the widget metadata that defines the size, layout, and update rate for your widget using the following attributes:

> initialLayout The layout resource to use in constructing the widget's user interface.

> minWidth / minHeight Respectively, the minimum width and minimum height of the widget, as described in the previous section.

> label The title used by your widget in the widget-picker.

> updatePeriodMillis The minimum period between widget updates in milliseconds. Android will wake the device to update your widget at this rate, so you should specify at least an hour. Ideally your widget shouldn't use this update technique more than once or twice daily. More details on this and other update techniques are provided later in this chapter.

> configure You can optionally specify a fully qualified Activity to be launched when your widget is added to the home screen. This Activity can be used to specify widget settings and user preferences. Using a configuration Activity is described later in this chapter.

Listing 10-2 shows the widget resource file for a two-cell-by-two-cell widget that updates once every hour and uses the layout resource defined in the previous section.

Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment