Java Code Examples for android.app.SearchManager#getSearchablesInGlobalSearch()

The following examples show how to use android.app.SearchManager#getSearchablesInGlobalSearch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From PacketSender-Android with MIT License 6 votes vote down vote up
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;
                }
            }
            mSearchView.setSearchableInfo(info);
        }

        mSearchView.setOnQueryTextListener(this);
    }
 
Example 2
Source File: SearchActivity.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
private void setupSearchView(MenuItem searchItem) {

        mSearchView.setIconifiedByDefault(false);

        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.setSearchableInfo(info);
        }

        mSearchView.setOnQueryTextListener(this);
        mSearchView.setFocusable(false);
        mSearchView.setFocusableInTouchMode(false);
    }
 
Example 3
Source File: SearchActivity.java    From search-samples with Apache License 2.0 6 votes vote down vote up
private void setupSearchView(MenuItem searchItem) {

        mSearchView.setIconifiedByDefault(false);

        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.setSearchableInfo(info);
        }

        mSearchView.setOnQueryTextListener(this);
        mSearchView.setFocusable(false);
        mSearchView.setFocusableInTouchMode(false);
    }
 
Example 4
Source File: SearchViewActionBar.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
private void setupSearchView(MenuItem searchItem) {

        if (isAlwaysExpanded()) {
            mSearchView.setIconifiedByDefault(false);
        } else {
            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();

            // Try to use the "applications" global search provider
            SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
            for (SearchableInfo inf : searchables) {
                if (inf.getSuggestAuthority() != null
                        && inf.getSuggestAuthority().startsWith("applications")) {
                    info = inf;
                }
            }
            mSearchView.setSearchableInfo(info);
        }

        mSearchView.setOnQueryTextListener(this);
    }
 
Example 5
Source File: ProductsFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    //menu.clear();
    super.onCreateOptionsMenu(menu,inflater);
    inflater.inflate(R.menu.product_fragment_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    if (searchView != null) {
        List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
        SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
        for (SearchableInfo inf : searchables) {
            if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
                info = inf;
            }
        }
        searchView.setSearchableInfo(info);
        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint(getActivity().getString(R.string.product_title_search));

        if(mQuery != null && mQuery.length() > 0) {
            searchView.setQuery(mQuery, true);
            searchView.setIconifiedByDefault(false);
            searchView.performClick();
            searchView.requestFocus();
        } else {
            searchView.setIconifiedByDefault(true);
        }
    }

}
 
Example 6
Source File: CustomersFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    //menu.clear();
    super.onCreateOptionsMenu(menu,inflater);
    inflater.inflate(R.menu.customer_fragment_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    if (searchView != null) {
        List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
        SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
        for (SearchableInfo inf : searchables) {
            if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
                info = inf;
            }
        }
        searchView.setSearchableInfo(info);
        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint(getActivity().getString(R.string.customer_title_search));

        if(mQuery != null && mQuery.length() > 0) {
            searchView.setQuery(mQuery, true);
            searchView.setIconifiedByDefault(false);
            searchView.performClick();
            searchView.requestFocus();
        } else {
            searchView.setIconifiedByDefault(true);
        }
    }

}
 
Example 7
Source File: OrdersFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    //menu.clear();
    super.onCreateOptionsMenu(menu,inflater);
    inflater.inflate(R.menu.order_fragment_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    if (searchView != null) {
        List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
        SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
        for (SearchableInfo inf : searchables) {
            if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
                info = inf;
            }
        }
        searchView.setSearchableInfo(info);
        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint(getActivity().getString(R.string.order_title_search));

        if(mQuery != null && mQuery.length() > 0) {
            searchView.setQuery(mQuery, true);
            searchView.setIconifiedByDefault(false);
            searchView.performClick();
            searchView.requestFocus();
        } else {
            searchView.setIconifiedByDefault(true);
        }
    }

}
 
Example 8
Source File: ProductsFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    //menu.clear();
    super.onCreateOptionsMenu(menu,inflater);
    inflater.inflate(R.menu.product_fragment_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    if (searchView != null) {
        List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
        SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
        for (SearchableInfo inf : searchables) {
            if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
                info = inf;
            }
        }
        searchView.setSearchableInfo(info);
        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint(getActivity().getString(R.string.product_title_search));

        if(mQuery != null && mQuery.length() > 0) {
            searchView.setQuery(mQuery, true);
            searchView.setIconifiedByDefault(false);
            searchView.performClick();
            searchView.requestFocus();
        } else {
            searchView.setIconifiedByDefault(true);
        }
    }

}
 
Example 9
Source File: CustomersFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    //menu.clear();
    super.onCreateOptionsMenu(menu,inflater);
    inflater.inflate(R.menu.customer_fragment_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    if (searchView != null) {
        List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
        SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
        for (SearchableInfo inf : searchables) {
            if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
                info = inf;
            }
        }
        searchView.setSearchableInfo(info);
        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint(getActivity().getString(R.string.customer_title_search));

        if(mQuery != null && mQuery.length() > 0) {
            searchView.setQuery(mQuery, true);
            searchView.setIconifiedByDefault(false);
            searchView.performClick();
            searchView.requestFocus();
        } else {
            searchView.setIconifiedByDefault(true);
        }
    }

}
 
Example 10
Source File: OrdersFragment.java    From Woodmin with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    //menu.clear();
    super.onCreateOptionsMenu(menu,inflater);
    inflater.inflate(R.menu.order_fragment_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    if (searchView != null) {
        List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
        SearchableInfo info = searchManager.getSearchableInfo(getActivity().getComponentName());
        for (SearchableInfo inf : searchables) {
            if (inf.getSuggestAuthority() != null && inf.getSuggestAuthority().startsWith("applications")) {
                info = inf;
            }
        }
        searchView.setSearchableInfo(info);
        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint(getActivity().getString(R.string.order_title_search));

        if(mQuery != null && mQuery.length() > 0) {
            searchView.setQuery(mQuery, true);
            searchView.setIconifiedByDefault(false);
            searchView.performClick();
            searchView.requestFocus();
        } else {
            searchView.setIconifiedByDefault(true);
        }
    }

}