: Beginning Android

Update the Manifest

Update the Manifest

While this implements search, it doesnt tie it into the Android search system. That requires a few changes to the auto-generated AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<activity android:name=".LoremDemo" android:label="LoremDemo">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<meta-data android:name="android.app.default_searchable"
android:value=".LoremSearch" />
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />

The changes needed are as follows:

1.The LoremDemo main activity gets a meta-data element, with an android:name of android.app.default_searchable and a android:value of the search implementation class (.LoremSearch).

2.The LoremSearch activity gets an intent filter for android.intent.action.SEARCH, so search intents will be picked up.

3.The LoremSearch activity is set to have android:launchMode="singleTop", which means at most one instance of this activity will be open at any time so we dont wind up with a whole bunch of little search activities cluttering up the activity stack.

4.The LoremSearch activity gets a meta-data element, with an android:name of android.app.searchable and a android:value of an XML resource containing more information about the search facility offered by this activity (@xml/searchable).

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:hint="@string/searchHint" />

That XML resource provides two bits of information today:

What name should appear in the search domain button to the right of the search field, identifying to the user where they are searching (android:label)

What hint text should appear in the search field, to give the user a clue as to what they should be typing in (android:hint)

: 1.323. /Cache: 3 / 0