Android Programming Tutorials

(Romina) #1
A Restaurant In Your Own Home

Step #5: Update the Manifest


Now, we can add our widget to the manifest file. Edit AndroidManifest.xml


to look like the following:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="apt.tutorial"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name">
<activity android:name=".LunchList"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
<meta-data android:name="android.app.default_searchable"
android:value=".LunchList" />
</activity>
<activity android:name=".DetailForm">
</activity>
<activity android:name=".EditPreferences">
</activity>
<receiver android:name=".AppWidget"
android:label="@string/app_name"
android:icon="@drawable/icon">
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_provider" />
</receiver>
</application>
</manifest>

In particular, note the element towards the bottom – that is


where we are teaching Android where our code and metadata resides for


this app widget. The intent filter for APPWIDGET_UPDATE means that we will


get control when Android wants us to update the app widget's contents,


such as when the app widget is first added to the home screen.


318
Free download pdf