Declaring an App Widget in the Manifest

First, declare the AppWidgetProvider class in your application's AndroidManifest.xml file. For example:

<receiver android:name="ExampleAppWidgetProvider" > <intent-filter>

<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter>

<meta-data android:name="android.appwidget.provider"

android:resource="@xml/example appwidget info" />

</receiver>

The <receiver> element requires the android:name attribute, which specifies the AppWidgetProvider used by the App Widget.

The <intent-filter> element must include an <action> element with the android:name attribute. This attribute specifies that the AppWidgetProvider accepts theACTION APPWIDGET UPDATE broadcast. This is the only broadcast that you must explicitly declare. The AppWidgetManager automatically sends all other App Widget broadcasts to the AppWidgetProvider as necessary.

The <meta-data> element specifies the AppWidgetProviderlnfo resource and requires the following attributes:

• android:name - Specifies the metadata name. Use android .appwidget.provider to identify the data as the AppWidgetProviderlnfo descriptor.

• android:resource - Specifies the AppWidgetProviderlnfo resource location.

0 0

Post a comment