Example usage for android.app SearchManager getSearchableInfo

List of usage examples for android.app SearchManager getSearchableInfo

Introduction

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

Prototype

public SearchableInfo getSearchableInfo(ComponentName componentName) 

Source Link

Document

Gets information about a searchable activity.

Usage

From source file:android.support.test.testapp.ActionBarSearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    inflater.inflate(R.menu.actionbar_search_actions, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    return super.onCreateOptionsMenu(menu);
}

From source file:se.chalmers.watchme.activity.TagMovieListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);

    /*// w w w. j  a  v  a  2s . c  o m
     * It should not be possible to mail or sort in this activity
     */
    MenuItem mailItem = menu.findItem(R.id.menu_send_email_button);
    mailItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem sortItem = menu.findItem(R.id.menu_sort_button);
    sortItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    /*
     * Add necessary functionality for the search widget
     */
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search_button).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget;
    // expand it by default

    return true;
}

From source file:org.bwgz.quotation.activity.QuotationsActivity.java

public boolean onCreateOptionsMenu(final Menu menu) {
    Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu));

    getMenuInflater().inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint(getString(R.string.search_keyword));

    final ListView drawerView = (ListView) findViewById(R.id.drawer_view);
    DrawerAdapter adapter = new DrawerAdapter(getResources().getStringArray(R.array.quotations_drawer), 1);
    drawerView.setAdapter(adapter);// w  w w .  ja  v a 2  s . c o  m
    drawerView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, String.format("drawer - onItemClick - parent: %s  view: %s  position: %d  id: %d",
                    parent, view, position, id));

            if (id == 0) {
                drawerLayout.closeDrawer(drawerView);
                startActivity(new Intent(parent.getContext(), HomeActivity.class));
            }
        }
    });

    return true;
}

From source file:com.fastbootmobile.encore.app.SearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;/*from   w  w  w  .j a v a 2  s . c o  m*/
}

From source file:org.bwgz.quotation.activity.SubjectsActivity.java

public boolean onCreateOptionsMenu(final Menu menu) {
    Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu));

    getMenuInflater().inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint(getString(R.string.search_subject));

    final ListView drawerView = (ListView) findViewById(R.id.drawer_view);
    DrawerAdapter adapter = new DrawerAdapter(getResources().getStringArray(R.array.subjects_drawer), 1);
    drawerView.setAdapter(adapter);/*  w w w .j  a  v a2s  .  c  o  m*/
    drawerView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, String.format("drawer - onItemClick - parent: %s  view: %s  position: %d  id: %d",
                    parent, view, position, id));

            if (id == 0) {
                drawerLayout.closeDrawer(drawerView);
                startActivity(new Intent(parent.getContext(), HomeActivity.class));
            }
        }
    });

    return true;
}

From source file:com.conferenceengineer.android.iosched.ui.SearchActivity.java

@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.search, menu);
    final MenuItem searchItem = menu.findItem(R.id.menu_search);
    if (searchItem != null && UIUtils.hasHoneycomb()) {
        SearchView searchView = (SearchView) searchItem.getActionView();
        if (searchView != null) {
            SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
            searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
            searchView.setQueryRefinementEnabled(true);
            searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                @Override/* w  w  w. j a  v  a  2  s  .c  o  m*/
                public boolean onQueryTextSubmit(String s) {
                    ReflectionUtils.tryInvoke(searchItem, "collapseActionView");
                    return false;
                }

                @Override
                public boolean onQueryTextChange(String s) {
                    return false;
                }
            });
            searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() {
                @Override
                public boolean onSuggestionSelect(int i) {
                    return false;
                }

                @Override
                public boolean onSuggestionClick(int i) {
                    ReflectionUtils.tryInvoke(searchItem, "collapseActionView");
                    return false;
                }
            });
        }
    }
    return true;
}

From source file:fr.outadev.skinswitch.GalleryActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.skin_library, menu);

    //set up search view
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);

    return true;/*from   ww  w.  ja  va 2  s  .  c  o m*/
}

From source file:atv.com.project.monkeylivetv.Activity.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // menu.clear();
    getMenuInflater().inflate(R.menu.main_menu, menu);

    //Share// ww  w. j  a  v a  2  s . co m
    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);
    setShareIntent(createShareIntent());

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

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(
            searchManager.getSearchableInfo(new ComponentName(this, SearchableActivity.class)));
    searchView.setIconifiedByDefault(false);

    return true;
}

From source file:com.thelastcrusade.soundstream.SearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    getMenuInflater().inflate(R.menu.search_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.search);
    SearchView searchView = (SearchView) searchItem.getActionView();

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);

    return true;//from  w w w .j  a v a2 s. com
}

From source file:se.chalmers.watchme.activity.SearchableActivity.java

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);

    /*/* ww w .j av a2s  .c  o  m*/
     * It should not be possible to mail or sort in this activity
     */
    MenuItem mailItem = menu.findItem(R.id.menu_send_email_button);
    mailItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem sortItem = menu.findItem(R.id.menu_sort_button);
    sortItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    /*
     * Add necessary functionality for the search widget
     */
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search_button).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget;
    // expand it by default

    return true;
}