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:edu.cmu.cylab.starslinger.view.PickRecipientsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Safeslinger);
    super.onCreate(savedInstanceState);

    // inject view
    setContentView(R.layout.pickrecipients);

    final ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    bar.setTitle(R.string.app_name);//from www .j  ava2  s.c o m
    bar.setSubtitle(R.string.title_PickRecipient);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    mSearchEdt = (SearchView) findViewById(R.id.fragment_address_search);
    ((AutoCompleteTextView) mSearchEdt.findViewById(R.id.search_src_text))
            .setDropDownBackgroundResource(R.drawable.abc_search_dropdown_light);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchEdt.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchEdt.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            // TODO Auto-generated method stub
            return false;
        }

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

    cbMostRecentOnly = (CheckBox) findViewById(R.id.ShowRecentCheckBox);
    listViewRecipients = (ListView) findViewById(R.id.RecipPickTableLayoutMembers);
    tvInstruct = (TextView) findViewById(R.id.tvInstruct);

    // always default to checked on view creation
    cbMostRecentOnly.setChecked(true);

    listViewRecipients.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            // nothing to do...
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            // save list position
            if (visibleItemCount != 0) {
                mListVisiblePos = firstVisibleItem;
                View v = listViewRecipients.getChildAt(0);
                mListTopOffset = (v == null) ? 0 : v.getTop();
            }
        }
    });

    cbMostRecentOnly.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateValues(null);
        }
    });

    updateValues(getIntent().getExtras());
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
    mTheme = Prefs.getCurrentThemeID(this);
    setTheme(mTheme);//w  w w  . j a  v  a  2  s  .c o  m

    super.onCreate(savedInstanceState);

    // check if caller has a gerrit instance start screen preference
    String suppliedGerritInstance = getIntent().getStringExtra(GERRIT_INSTANCE);
    if (suppliedGerritInstance != null && !suppliedGerritInstance.isEmpty()
            && suppliedGerritInstance.contains("http")) {
        // just set the prefs and allow normal loading
        Prefs.setCurrentGerrit(this, suppliedGerritInstance);
    }

    GoogleAnalytics googleAnalytics = GoogleAnalytics.getInstance(this);

    String trackingId = getString(R.string.ga_trackingId);
    Tracker tracker = googleAnalytics.getTracker(trackingId);
    googleAnalytics.getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
    tracker.send(MapBuilder.createAppView().build());

    // keep a log of what ROM our users run
    AnalyticsHelper.sendAnalyticsEvent(this, AnalyticsHelper.GA_APP_OPEN, AnalyticsHelper.GA_ROM_VERSION,
            ROMHelper.determineRom(this), null);

    // Keep track of what theme is being used
    AnalyticsHelper.sendAnalyticsEvent(this, AnalyticsHelper.GA_APP_OPEN, AnalyticsHelper.GA_THEME_SET_ON_OPEN,
            Prefs.getCurrentTheme(this), null);

    setContentView(R.layout.main);

    FragmentManager fm = getSupportFragmentManager();
    if (findViewById(R.id.change_detail_fragment) != null) {
        // The detail container view will be present only in
        // large-screen layouts(res/values-sw600dp). If this view is present,
        // then the activity should be in two-pane mode.
        mTwoPane = true;
        mChangeDetail = (PatchSetViewerFragment) fm.findFragmentById(R.id.change_detail_fragment);
    }
    Prefs.setTabletMode(this, mTwoPane);

    mChangeList = (ChangeListFragment) fm.findFragmentById(R.id.change_list_fragment);

    mGerritWebsite = Prefs.getCurrentGerrit(this);

    // 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.thatkawaiiguy.meleehandbook.activity.SearchResultsActivity.java

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

    ComponentName cn = new ComponentName(this, SearchResultsActivity.class);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.searchview));

    searchView.onActionViewExpanded();/*from w w  w .ja va  2s. c  o  m*/

    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        searchView.setQuery(getIntent().getStringExtra(SearchManager.QUERY).replaceAll("\\s+$", ""), false);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(cn));
        searchView.clearFocus();
    }

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (!query.equals(""))
                search(query);
            searchView.clearFocus();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (!newText.equals(""))
                search(newText);
            return false;
        }
    });

    return super.onCreateOptionsMenu(menu);
}

From source file:de.aw.monma.actions.FragmentWPList.java

/**
 * In der ActionBar die SearchView initialisieren
 *//*from   w ww  .j a va 2 s  . co m*/
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_wplist, menu);
    menu.findItem(R.id.menu_item_onlyBestand).setChecked(onlyBestand);
    menu.findItem(R.id.menu_item_sortieren).setChecked(sortieren);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_List_search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setOnQueryTextListener(this);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.stoneapp.ourvlemoodle2.fragments.MembersFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE);

        searchitem = menu.findItem(R.id.action_search);
        searchView = (SearchView) MenuItemCompat.getActionView(searchitem); // set up search view

        searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));

        searchView.setOnQueryTextListener(this);
        searchView.setQueryHint("Search name");

        searchView.setOnCloseListener(new SearchView.OnCloseListener() {
            @Override/*  ww  w .j  av  a 2s. co m*/
            public boolean onClose() {
                searchView.setQuery("", false); // clears text from search view
                return true;
            }
        });
    }
}

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

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

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);
    searchView.setOnQueryTextListener(this);

    return true;//from w ww  .  ja v a2s .co  m
}

From source file:algolia.com.demo.moviesearch.ui.MovieSearchActivity.java

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

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

    return true;/*from  w  w w  .ja va2s.  com*/
}

From source file:com.google.samples.apps.sergio.ui.SearchActivity.java

@Override
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) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        final SearchView view = (SearchView) searchItem.getActionView();
        mSearchView = view;/*from  w ww.j a  v a  2s.c o m*/
        if (view == null) {
            LOGW(TAG, "Could not set up search view, view is null.");
        } else {
            view.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
            view.setIconified(false);
            view.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String s) {
                    view.clearFocus();
                    if ("zzznotif".equals(s)) {
                        (new ShowFeedbackNotificationAction()).run(SearchActivity.this, null);
                    }
                    return true;
                }

                @Override
                public boolean onQueryTextChange(String s) {
                    if (null != mSessionsFragment) {
                        mSessionsFragment.requestQueryUpdate(s);
                    }
                    return true;
                }
            });
            view.setOnCloseListener(new SearchView.OnCloseListener() {
                @Override
                public boolean onClose() {
                    finish();
                    return false;
                }
            });
        }

        if (!TextUtils.isEmpty(mQuery)) {
            view.setQuery(mQuery, false);
        }
    }
    return true;
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.SignBrowserFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    Log.d(TAG, "onCreateOptionsMenu " + hashCode());
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.options_sign_browser, menu);
    final MenuItem item = menu.findItem(R.id.action_toggle_starred);
    if (this.showStarredOnly) {
        item.setIcon(R.drawable.ic_sign_browser_grade_checked);
    } else {//from   w ww  .  j ava  2s .co m
        item.setIcon(R.drawable.ic_sign_browser_grade_no_stroke);
    }
    final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
}

From source file:com.android.mail.ui.ActionBarController.java

public boolean onCreateOptionsMenu(Menu menu) {
    mEmptyTrashItem = menu.findItem(R.id.empty_trash);
    mEmptySpamItem = menu.findItem(R.id.empty_spam);
    mSearch = menu.findItem(R.id.search);

    if (mSearch != null) {
        mSearchWidget = (SearchView) MenuItemCompat.getActionView(mSearch);
        MenuItemCompat.setOnActionExpandListener(mSearch, this);
        SearchManager searchManager = (SearchManager) mActivity.getActivityContext()
                .getSystemService(Context.SEARCH_SERVICE);
        if (searchManager != null && mSearchWidget != null) {
            SearchableInfo info = searchManager.getSearchableInfo(mActivity.getComponentName());
            mSearchWidget.setSearchableInfo(info);
            mSearchWidget.setOnQueryTextListener(this);
            mSearchWidget.setOnSuggestionListener(this);
            mSearchWidget.setIconifiedByDefault(true);
        }//  ww  w. j  a  v a2 s.c o m
    }

    // the menu should be displayed if the mode is known
    return getMode() != ViewMode.UNKNOWN;
}