List of usage examples for android.content Context SEARCH_SERVICE
String SEARCH_SERVICE
To view the source code for android.content Context SEARCH_SERVICE.
Click Source Link
From source file:com.android.launcher3.QsbContainerView.java
/** * Returns a widget with category {@link AppWidgetProviderInfo#WIDGET_CATEGORY_SEARCHBOX} * provided by the same package which is set to be global search activity. * If widgetCategory is not supported, or no such widget is found, returns the first widget * provided by the package./*ww w . j ava2 s . c om*/ */ public static AppWidgetProviderInfo getSearchWidgetProvider(Context context) { SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); ComponentName searchComponent = searchManager.getGlobalSearchActivity(); if (searchComponent == null) return null; String providerPkg = searchComponent.getPackageName(); AppWidgetProviderInfo defaultWidgetForSearchPackage = null; AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); for (AppWidgetProviderInfo info : appWidgetManager.getInstalledProviders()) { if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) { if ((info.widgetCategory & AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) { return info; } else if (defaultWidgetForSearchPackage == null) { defaultWidgetForSearchPackage = info; } } } return defaultWidgetForSearchPackage; }
From source file:org.addhen.smssync.presentation.view.ui.activity.MainActivity.java
private void initSearchView() { final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.clearFocus();//from ww w.j ava 2 s.c o m mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { mSearchView.clearFocus(); performQuery(s); return true; } @Override public boolean onQueryTextChange(String s) { performQuery(s); return true; } }); mSearchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { reloadMessages(); return false; } }); if (!TextUtils.isEmpty(mQuery)) { mSearchView.setQuery(mQuery, false); } SearchView.SearchAutoComplete searchAutoComplete = (SearchView.SearchAutoComplete) mSearchView .findViewById(android.support.v7.appcompat.R.id.search_src_text); searchAutoComplete.setHintTextColor(getResources().getColor(android.R.color.white)); searchAutoComplete.setTextSize(14); }
From source file:dev.vision.shopping.center.Fragments.GourmetFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { //inflater.inflate(R.menu.main, menu); inflater.inflate(R.menu.offers, menu); MenuItem searchItem = menu.findItem(R.id.action_search); MenuItem expand = menu.findItem(R.id.expand); expand.setVisible(false);/*from www . j a va 2 s .co m*/ SearchView searchView = null; searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView == null) searchView = (SearchView) searchItem.getActionView(); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); searchView.setOnQueryTextListener(this); }
From source file:itcr.gitsnes.MainActivity.java
/** * Methods inflate menu options panel//from ww w. ja va 2 s .c o m * Params: * - [menu] * Returns: * - State of building [true] */ @Override public boolean onCreateOptionsMenu(Menu menu) { /* Inflate the menu; this adds items to the action bar if it is present. */ getMenuInflater().inflate(R.menu.main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); if (null != searchView) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); } SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { public boolean onQueryTextChange(String newText) { // this is your adapter that will be filtered // Log.i("log_tag",newText); return true; } public boolean onQueryTextSubmit(String query) { Log.i("log_tag", query); MasterGames new_fragment = new MasterGames(json_arr); new_fragment.setQname(query); RelativeLayout rl = (RelativeLayout) findViewById(R.id.mainback); rl.setBackgroundColor(Color.parseColor("#009f28")); authButton.setVisibility(View.INVISIBLE); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.placeholder, new_fragment); transaction.addToBackStack(null); transaction.commit(); return true; } }; searchView.setOnQueryTextListener(queryTextListener); return super.onCreateOptionsMenu(menu); }
From source file:com.terracom.mumbleclient.channel.ChannelListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_channel_list, menu); MenuItem searchItem = menu.findItem(R.id.menu_search); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override//from w w w. jav a2s.c o m public boolean onSuggestionSelect(int i) { return false; } @Override public boolean onSuggestionClick(int i) { CursorWrapper cursor = (CursorWrapper) searchView.getSuggestionsAdapter().getItem(i); int typeColumn = cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA); int dataIdColumn = cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_DATA); String itemType = cursor.getString(typeColumn); int itemId = cursor.getInt(dataIdColumn); if (ChannelSearchProvider.INTENT_DATA_CHANNEL.equals(itemType)) { try { if (getService().getSessionChannel().getId() != itemId) { getService().joinChannel(itemId); } else { scrollToChannel(itemId); } } catch (RemoteException e) { e.printStackTrace(); } return true; } else if (ChannelSearchProvider.INTENT_DATA_USER.equals(itemType)) { scrollToUser(itemId); return true; } return false; } }); }
From source file:com.morlunk.mumbleclient.channel.ChannelListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fragment_channel_list, menu); MenuItem searchItem = menu.findItem(R.id.menu_search); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override//from w w w .jav a 2 s . com public boolean onSuggestionSelect(int i) { return false; } @Override public boolean onSuggestionClick(int i) { CursorWrapper cursor = (CursorWrapper) searchView.getSuggestionsAdapter().getItem(i); int typeColumn = cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA); int dataIdColumn = cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_INTENT_DATA); String itemType = cursor.getString(typeColumn); int itemId = cursor.getInt(dataIdColumn); if (ChannelSearchProvider.INTENT_DATA_CHANNEL.equals(itemType)) { if (getService().getSessionChannel().getId() != itemId) { getService().joinChannel(itemId); } else { scrollToChannel(itemId); } return true; } else if (ChannelSearchProvider.INTENT_DATA_USER.equals(itemType)) { scrollToUser(itemId); return true; } return false; } }); }
From source file:com.google.android.apps.mytracks.util.Api11Adapter.java
@Override public void configureSearchWidget(Activity activity, final MenuItem menuItem) { SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menuItem.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); searchView.setQueryRefinementEnabled(true); }
From source file:org.y20k.transistor.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // inflate the menu items for use in the action bar MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_main_actionbar, menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return super.onCreateOptionsMenu(menu); }
From source file:mroza.forms.ChooseProgramActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; getMenuInflater().inflate(R.menu.choose_program_menu, menu); //Associate programs_searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); android.support.v7.widget.SearchView searchView = (android.support.v7.widget.SearchView) menu .findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); EditText searchPlate = (EditText) searchView .findViewById(android.support.v7.appcompat.R.id.search_src_text); searchPlate.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchPlate.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override//from www. j a va 2s.co m public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { //On search or enter clicked if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_NULL) { if (v.getText().toString().equals("")) { refreshChildTableList(); clearSearchField(); clearFilters(true); enableShowAllButton(false); } } return false; } }); restoreSavedFilters(); return true; }
From source file:com.ht.app.RestaurantsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); mMenu = menu;/*from ww w.j a va2 s . c o m*/ MenuItem searchMenuItem = (MenuItem) menu.findItem(R.id.action_search); MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem menuItem) { // mToolbar.setIcon(android.R.color.transparent); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem menuItem) { return true; } }); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search)); // Assumes current activity is the searchable activity mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default // Style search widget and suggestion list LinearLayout linearLayout1 = (LinearLayout) mSearchView.getChildAt(0); LinearLayout linearLayout2 = (LinearLayout) linearLayout1.getChildAt(2); LinearLayout linearLayout3 = (LinearLayout) linearLayout2.getChildAt(1); AutoCompleteTextView autoComplete = (AutoCompleteTextView) linearLayout3.getChildAt(0); autoComplete.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { hideSearchWidget(); } } }); autoComplete.setTextColor(Color.WHITE); autoComplete.setHintTextColor(Color.WHITE); autoComplete.setDropDownBackgroundResource(R.color.app_red_color); return true; }