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:com.example.android.supportv7.app.ToolbarUsage.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actions, menu);

    // Retrieve the SearchView and plug it into SearchManager
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));

    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;/*from   www  . j a  v a2 s.c  o  m*/
}

From source file:com.conferenceengineer.android.iosched.ui.phone.SessionsActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/* w  ww  .  j a v a  2 s.c om*/
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.search, menu);
    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);
        }
    }
    return true;
}

From source file:com.github.rutvijkumar.twittfuse.activities.BaseFragmentActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.tweets_menus, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    searchView = (SearchView) searchItem.getActionView();
    Util.setupSearchView(this, searchView);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    composeActionMenu = menu.findItem(R.id.action_compose);
    composeActionVisibility(false);/*from  www  .j av a  2s. c  o  m*/
    return true;
}

From source file:MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_options, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;/*from  w ww  .j  a  v  a 2 s.  com*/
}

From source file:com.vagabond.dealhunting.ui.SearchActivity.java

private void setupSearchView() {
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setIconified(false);//from w  w w. j a va 2s . c o  m
    // Set the query hint.
    mSearchView.setQueryHint(getString(R.string.search_hint));
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String s) {
            mSearchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            searchFor(s);
            return true;
        }
    });

    if (!TextUtils.isEmpty(mQuery)) {
        mSearchView.setQuery(mQuery, false);
    }
}

From source file:com.jbirdvegas.mgerrit.AOKPChangelog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.setTheme(Prefs.getCurrentThemeID(this));
    super.onCreate(savedInstanceState);

    setContentView(R.layout.aokp_changelog);

    // Action bar Up affordance
    getActionBar().setDisplayHomeAsUpEnabled(true);

    Prefs.setGerritInstanceByName(this, "AOKP");

    ChangelogFragment frag;//from ww w  .ja va2  s .c  o m
    frag = (ChangelogFragment) getSupportFragmentManager().findFragmentById(R.id.changelog_fragment);
    frag.setQuery(mQuery);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (GerritSearchView) findViewById(R.id.search);
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
}

From source file:com.gm.goldencity.activity.search.SearchActivity.java

public void setupSearchView() {
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchview.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    // hint, inputType & ime options seem to be ignored from XML! Set in code
    searchview.setQueryHint(getString(R.string.search_hint));
    searchview.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    searchview.setImeOptions(searchview.getImeOptions() | EditorInfo.IME_ACTION_SEARCH
            | EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN);

}

From source file:com.gnufabio.costituzione.SearchResultsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.actionbar_mainscreen, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);
    searchView.setOnQueryTextListener(this);

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

From source file:com.keylesspalace.tusky.SearchActivity.java

private void setupSearchView(SearchView searchView) {
    searchView.setIconifiedByDefault(false);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    if (searchManager != null) {
        SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
        searchView.setSearchableInfo(searchableInfo);
    }//from  ww w  .j  av  a2s  .  c  om

    searchView.setOnQueryTextListener(this);
    searchView.requestFocus();

    searchView.setMaxWidth(Integer.MAX_VALUE);
}

From source file:ca.rmen.android.palidamuerte.app.category.list.CategoriesActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.v(TAG, "onCreateOptionsMenu");
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_categories, menu);
    ActionBar.updateMusicMenuItem(this, menu.findItem(R.id.action_music));
    // Associate searchable configuration with the SearchView
    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   ww w  .ja va 2 s.c om*/
}