Example usage for android.content Context SEARCH_SERVICE

List of usage examples for android.content Context SEARCH_SERVICE

Introduction

In this page you can find the example usage for android.content Context SEARCH_SERVICE.

Prototype

String SEARCH_SERVICE

To view the source code for android.content Context SEARCH_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.app.SearchManager for handling searches.

Usage

From source file:at.flack.activity.NewFbContactActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.new_contact, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    searchView.setIconifiedByDefault(false);
    searchView.setIconified(false);//from  ww  w  . ja v  a  2 s  .c  o  m
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(this);
    return true;
}

From source file:no.group09.ucsoftwarestore.MainFragmentActivity.java

/**
 * Creates options menu/*from   w w  w  .j  a  v a 2s  .  c  om*/
 */
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);

    //When the menu is created, check the preferences and set the correct text
    if (sharedPref.getBoolean("hide_incompatible", false)) {
        menu.getItem(1).setTitle("Hide incompatible");
        menu.getItem(1).setChecked(true);
    } else {
        menu.getItem(1).setTitle("Hide incompatible");
        menu.getItem(1).setChecked(false);
    }

    //Search bar for versions over API level 11
    int SDK_INT = android.os.Build.VERSION.SDK_INT;

    if (SDK_INT >= 11) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();

        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setSubmitButtonEnabled(true);
    }
    return true;
}

From source file:com.actionbarsherlock.widget.SuggestionsAdapter.java

/**
 * The amount of time we delay in the filter when the user presses the delete key.
 *///  w w w . j a  v a  2  s .  c o m
//private static final long DELETE_KEY_POST_DELAY = 500L;

public SuggestionsAdapter(Context context, SearchView searchView, SearchableInfo searchable,
        WeakHashMap<String, Drawable.ConstantState> outsideDrawablesCache) {
    super(context, R.layout.abs__search_dropdown_item_icons_2line, null, // no initial cursor
            true); // auto-requery
    mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    mSearchable = searchable;
    mProviderContext = mContext;
    mSearchView = searchView;

    mOutsideDrawablesCache = outsideDrawablesCache;

    // mStartSpinnerRunnable = new Runnable() {
    // public void run() {
    // // mSearchView.setWorking(true); // TODO:
    // }
    // };
    //
    // mStopSpinnerRunnable = new Runnable() {
    // public void run() {
    // // mSearchView.setWorking(false); // TODO:
    // }
    // };

    // delay 500ms when deleting
    //  TODO  getFilter().setDelayer(new Filter.Delayer() {
    //
    //      private int mPreviousLength = 0;
    //
    //      public long getPostingDelay(CharSequence constraint) {
    //        if (constraint == null) return 0;
    //
    //        long delay = constraint.length() < mPreviousLength ? DELETE_KEY_POST_DELAY : 0;
    //        mPreviousLength = constraint.length();
    //        return delay;
    //      }
    //    });
}

From source file:com.scrachx.foodfacts.checker.ui.main.MainActivity.java

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

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) searchMenuItem.getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() {
        @Override/* w ww.  j a v a 2 s .c  om*/
        public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);

            // Not replace if no search has been done (no switch of fragment)
            if (currentFragment instanceof SearchFragment) {
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.fragment_container, SearchFragment.newInstance(), SearchFragment.TAG)
                        .commit();
            }

            return true;
        }
    });

    return true;
}

From source file:org.openmrs.client.activities.FindPatientsSearchActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//from   w  ww. j a  v a2  s .  co m
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.find_patients_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

    SearchView findPatientView;

    mFindPatientMenuItem = menu.findItem(R.id.actionSearch);
    if (OpenMRS.getInstance().isRunningHoneycombVersionOrHigher()) {
        findPatientView = (SearchView) mFindPatientMenuItem.getActionView();
    } else {
        findPatientView = (SearchView) MenuItemCompat.getActionView(mFindPatientMenuItem);
    }

    SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
    findPatientView.setSearchableInfo(info);
    findPatientView.setIconifiedByDefault(false);
    return true;
}

From source file:ufms.br.com.ufmsapp.fragment.NotasFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    getActivity().getMenuInflater().inflate(R.menu.notas_list_menu, menu);

    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search_nota).getActionView();
    searchView.setOnQueryTextListener(this);
    searchView.setQueryHint(getString(R.string.txt_busca));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
}

From source file:in.rab.ordboken.Ordboken.java

public SearchView initSearchView(Activity activity, Menu menu, String query, Boolean focus) {
    SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) activity.findViewById(R.id.mySearchView);

    searchView.setSearchableInfo(//  w w  w .ja va  2s  .  c om
            searchManager.getSearchableInfo(new ComponentName(activity, MainActivity.class)));

    // Hack to get the magnifying glass icon inside the EditText
    searchView.setIconifiedByDefault(true);
    searchView.setIconified(false);

    // Hack to get rid of the collapse button
    searchView.onActionViewExpanded();

    if (!focus) {
        searchView.clearFocus();
    }

    // searchView.setSubmitButtonEnabled(true);
    searchView.setQueryRefinementEnabled(true);

    if (query != null) {
        searchView.setQuery(query, false);
    }

    return searchView;
}

From source file:org.epstudios.epcoding.ProcedureDetailActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.shortmenu, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget;
    // expand it by default

    return super.onCreateOptionsMenu(menu);
}

From source file:it.gulch.linuxday.android.activities.SearchResultActivity.java

@SuppressLint("NewApi")
@Override/* ww w.  j  a  v  a  2  s. co  m*/
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search, menu);

    MenuItem searchMenuItem = menu.findItem(R.id.search);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        // Associate searchable configuration with the SearchView
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(false); // Always show the search view
        setSearchViewQuery(currentQuery);
    } else {
        // Legacy search mode for Eclair
        MenuItemCompat.setActionView(searchMenuItem, null);
        getSupportActionBar().setSubtitle(currentQuery);
    }
    return true;
}

From source file:com.tencent.wetest.activity.AppListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_app_list, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);

    SearchManager searchManager = (SearchManager) AppListActivity.this.getSystemService(Context.SEARCH_SERVICE);

    SearchView searchView = null;/*from  w  w  w  .j  av a 2  s.  com*/
    if (searchItem != null) {
        searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    }
    if (searchView != null) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(AppListActivity.this.getComponentName()));
    }

    if (searchView != null) {
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                filterAdpList(newText);
                return false;
            }
        });
    }

    return true;
}