Home Screen Widget step-by-step - define Widget Provider Receiver in AndroidManifest.xml

It's part of the Home Screen Widgets step-by-step series.

In this step, modify AndroidManifest.xml to add <receiver> to define Widget Provider Receiver.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidhomewidget"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- define Widget Provider Receiver -->
<receiver android:name=".WidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widgetproviderinfo" />
</receiver>

</application>

</manifest>


Pay attention how android:name=".WidgetProvider" and android:resource="@xml/widgetproviderinfo" correspond to WidgetProvider.java and /res/xml/widgetproviderinfo.xml respectively.

After modified AndroidManifest.xml to define Widget Provider Receiver, we can add our dummy Widget on Home Screen. Up to here, the widget do nothing actually!

The dummy Home Screen Widget

0 Response to "Home Screen Widget step-by-step - define Widget Provider Receiver in AndroidManifest.xml"

Posting Komentar