Aug 23, 2012

Home Screen Widget step-by-step - define app widget provider in XML

It's the first step of Home Screen Widgets: create a XML file, /res/xml/widgetproviderinfo.xml, to define  a minimal app widget provider info.

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:minWidth="146dp"
    android:minHeight="72dp"
    android:updatePeriodMillis="1800000"
    android:initialLayout="@layout/widget_layout">
</appwidget-provider>

Where:
  • android:minWidth and android:minHeight specify the minimum amount of space the App Widget consumes by default. The default Home screen positions App Widgets in its window based on a grid of cells that have a defined height and width. If the values for an App Widget's minimum width or height don't match the dimensions of the cells, then the App Widget dimensions round up to the nearest cell size.
  • android:updatePeriodMillis specify how often, in milliseconds, that this AppWidget wants to be updated. The AppWidget manager may place a limit on how often a AppWidget is updated.

    Note: Updates requested with updatePeriodMillis will not be delivered more than once every 30 minutes.
  • android:initialLayout specify the resource id of the initial layout for this AppWidget. We will implement it later.


Next Step >> Define widget layout.

No comments:

Post a Comment

Infolinks In Text Ads