Example usage for android.app SearchManager getSearchablesInGlobalSearch

List of usage examples for android.app SearchManager getSearchablesInGlobalSearch

Introduction

In this page you can find the example usage for android.app SearchManager getSearchablesInGlobalSearch.

Prototype

public List<SearchableInfo> getSearchablesInGlobalSearch() 

Source Link

Document

Returns a list of the searchable activities that can be included in global search.

Usage

From source file:com.packetsender.android.MainActivity.java

private void setupSearchView(MenuItem searchItem) {

    //searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    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;/*  w  w  w.j  a v a2s. c o  m*/
            }
        }
        mSearchView.setSearchableInfo(info);
    }

    mSearchView.setOnQueryTextListener(this);
}