Skip to content

Instantly share code, notes, and snippets.

@lethargicpanda
Created February 15, 2011 23:36
Show Gist options
  • Save lethargicpanda/828526 to your computer and use it in GitHub Desktop.
Save lethargicpanda/828526 to your computer and use it in GitHub Desktop.
XML describing the behavior of the android search dialog
<application ... >
<activity android:name=".MainSearchableActivity" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
...
</application>
[...]
public void onCreate(Bundle savedInstanceState) {
[...]
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
doMySearch(query);
}
}
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="Search in your_application_name" >
</searchable>
@lethargicpanda
Copy link
Author

Snippets used to implement the Android Search Dialog
http://developer.android.com/guide/topics/search/search-dialog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment