Skip to content

Instantly share code, notes, and snippets.

@chrislacy
Created April 17, 2013 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislacy/5402950 to your computer and use it in GitHub Desktop.
Save chrislacy/5402950 to your computer and use it in GitHub Desktop.
Gist to use the system search to search for apps
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
if (searchManager != null) {
List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
for (SearchableInfo inf : searchables) {
if (inf.getSuggestAuthority() != null
&& inf.getSuggestAuthority().startsWith("applications")) {
info = inf;
}
}
// mSearchView is an instance of SearchView
mSearchView.setSearchableInfo(info);
mSearchView.setSuggestionsAdapter(new QuicksearchAdapter(this, info, mSearchView));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment