Книга: Beginning Android
Update the Manifest
Update the Manifest
While this implements search, it doesn’t 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"
package="com.commonsware.android.search">
<application>
<activity android:name=".LoremDemo" android:label="LoremDemo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.default_searchable"
android:value=".LoremSearch" />
</activity>
<activity
android:name=".LoremSearch"
android:label="LoremSearch"
android:launchMode="singleTop">
<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" />
</activity>
</application>
</manifest>
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 don’t 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:label="@string/searchLabel"
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
)
- Manifest Destiny
- Step #4: Update the Manifest
- 4.4.4 The Dispatcher
- About the author
- Chapter 7. The state machine
- Appendix E. Other resources and links
- Example NAT machine in theory
- The final stage of our NAT machine
- Compiling the user-land applications
- The conntrack entries
- Untracked connections and the raw table
- Basics of the iptables command