List of usage examples for android.app SearchManager QUERY
String QUERY
To view the source code for android.app SearchManager QUERY.
Click Source Link
From source file:org.transdroid.gui.search.Search.java
/** * Extracts the query string from the search Intent * @return The string that was entered by the user *//*from ww w .ja v a2 s . c om*/ private String getQuery(Intent intent) { // Extract string from Intent String query = null; if (intent.getAction().equals(Intent.ACTION_SEARCH)) { query = intent.getStringExtra(SearchManager.QUERY); } else if (intent.getAction().equals(Intent.ACTION_SEND)) { query = SendIntentHelper.cleanUpText(intent); } if (query != null && query.length() > 0) { // Remember this search query to later show as a suggestion suggestions.saveRecentQuery(query, null); return query; } return null; }
From source file:fr.kwiatkowski.apktrack.MainActivity.java
/** * This method received the intents passed to the activity and processes them. * @param i The intent to handle.// w w w . j ava 2s . c o m */ private void _handle_intent(Intent i) { // The user wants to filter the list. if (Intent.ACTION_SEARCH.equals(i.getAction())) { Log.v(TAG, "User search: " + i.getStringExtra(SearchManager.QUERY)); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); boolean show_system = pref.getBoolean(SettingsFragment.KEY_PREF_SHOW_SYSTEM, false); String query = "%" + i.getStringExtra(SearchManager.QUERY) + "%"; String where_clause = "(_displayname LIKE ? OR _packagename LIKE ?)"; if (!show_system) { where_clause += " AND _systemapp = 0"; } List<InstalledApp> results = InstalledApp.find(InstalledApp.class, where_clause, query, query); Log.v(TAG, results.size() + " application(s) match."); if (results.size() == 0) // No apps match the search. { Toast.makeText(getApplicationContext(), R.string.search_no_result, Toast.LENGTH_SHORT).show(); return; } _app_display.filter_apps(results); } else if (Intent.ACTION_MANAGE_NETWORK_USAGE.equals(i.getAction())) { // Do not add to the backstack: back should return to the Intent sender. getSupportFragmentManager().beginTransaction().replace(R.id.container, new SettingsFragment()).commit(); } }
From source file:com.nagopy.android.mypkgs.MainActivity.java
@SuppressWarnings("unused") @Subscribe/*from ww w . ja va2s . c o m*/ public void onActionItemClicked(MultiChoiceModeListenerEvent.ActionItemClickedEvent event) { int id = event.menuItem.getItemId(); List<AppData> checkedItemList = event.checkedItemList; switch (id) { case R.id.action_search: if (checkedItemList.isEmpty()) { throw new RuntimeException("Checked item is empty!"); } AppData selected = checkedItemList.get(0); if (canLaunchImplicitIntent(Intent.ACTION_WEB_SEARCH)) { Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, makeSearchQuery(selected)); startActivity(intent); } else { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(makeSearchUrl(selected))); startActivity(intent); } break; case R.id.action_share_label: sendIntent(ShareType.LABEL.makeShareString(checkedItemList)); break; case R.id.action_share_package_name: sendIntent(ShareType.PACKAGE.makeShareString(checkedItemList)); break; case R.id.action_share_label_and_package_name: sendIntent(ShareType.LABEL_AND_PACKAGE.makeShareString(checkedItemList)); break; case R.id.action_share_csv: sendIntent(ShareType.CSV.makeShareString(checkedItemList)); break; case 0: // skip break; default: throw new RuntimeException("unknown id:" + id); } }
From source file:com.streaming.sweetplayer.MainActivity.java
private void handleIntent(Intent intent) { try {/*www . j ava2s . c om*/ if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); // Log.d(TAG, "Search: " + query); SearchFragment searchFragment = new SearchFragment(); addFragment(searchFragment); searchFragment.searchSongs(query); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.timemachine.controller.ControllerActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String input = intent.getStringExtra(SearchManager.QUERY); String suggestion = (String) intent.getExtras().get("intent_extra_data_key"); String query;/* w ww . java2 s.c o m*/ // Use the query to search your data somehow if (suggestion == null) query = input; else query = suggestion; Geocoder geocoder = new Geocoder(ControllerActivity.this); try { List<Address> address = geocoder.getFromLocationName(query, 1); if (address != null && !address.isEmpty()) { Address location = address.get(0); System.out.println(location.getLatitude() + ", " + location.getLongitude()); mMap.animateCamera( CameraUpdateFactory.newLatLngZoom( new LatLng(location.getLatitude(), location.getLongitude()), maxZoom), animateCameraDuration, null); } else System.out.println("No address found."); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.cyanogenmod.eleven.ui.activities.SearchActivity.java
/** * {@inheritDoc}// w ww. j av a 2s .com */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPopupMenuHelper = new PopupMenuHelper(this, getSupportFragmentManager()) { private SearchResult mSelectedItem; @Override public PopupMenuType onPreparePopupMenu(int position) { mSelectedItem = mAdapter.getTItem(position); return PopupMenuType.SearchResult; } @Override protected long[] getIdList() { switch (mSelectedItem.mType) { case Artist: return MusicUtils.getSongListForArtist(SearchActivity.this, mSelectedItem.mId); case Album: return MusicUtils.getSongListForAlbum(SearchActivity.this, mSelectedItem.mId); case Song: return new long[] { mSelectedItem.mId }; case Playlist: return MusicUtils.getSongListForPlaylist(SearchActivity.this, mSelectedItem.mId); default: return null; } } @Override protected long getSourceId() { return mSelectedItem.mId; } @Override protected Config.IdType getSourceType() { return mSelectedItem.mType.getSourceType(); } @Override protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) { super.updateMenuIds(type, set); if (mSelectedItem.mType == ResultType.Album) { set.add(FragmentMenuItems.MORE_BY_ARTIST); } } @Override protected String getArtistName() { return mSelectedItem.mArtist; } }; // Fade it in overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); // Control the media volume setVolumeControlStream(AudioManager.STREAM_MUSIC); // Bind Apollo's service mToken = MusicUtils.bindToService(this, this); // Set the layout setContentView(R.layout.activity_search); // get the input method manager mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Initialize the adapter SummarySearchAdapter adapter = new SummarySearchAdapter(this); mAdapter = new SectionAdapter<SearchResult, SummarySearchAdapter>(this, adapter); // Set the prefix mAdapter.getUnderlyingAdapter().setPrefix(mFilterString); mAdapter.setupHeaderParameters(R.layout.list_search_header, false); mAdapter.setupFooterParameters(R.layout.list_search_footer, true); mAdapter.setPopupMenuClickedListener(new IPopupMenuCallback.IListener() { @Override public void onPopupMenuClicked(View v, int position) { mPopupMenuHelper.showPopupMenu(v, position); } }); mLoadingEmptyContainer = (LoadingEmptyContainer) findViewById(R.id.loading_empty_container); // setup the no results container NoResultsContainer noResults = mLoadingEmptyContainer.getNoResultsContainer(); noResults.setMainText(R.string.empty_search); noResults.setSecondaryText(R.string.empty_search_check); initListView(); // setup handler and runnable mHandler = new Handler(); mLoadingRunnable = new Runnable() { @Override public void run() { setState(VisibleState.Loading); } }; // Theme the action bar final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); // Get the query String mFilterString = getIntent().getStringExtra(SearchManager.QUERY); // if we have a non-empty search string, this is a 2nd lvl search if (!TextUtils.isEmpty(mFilterString)) { mTopLevelSearch = false; // get the search type to filter by int type = getIntent().getIntExtra(SearchManager.SEARCH_MODE, -1); if (type >= 0 && type < ResultType.values().length) { mSearchType = ResultType.values()[type]; } int resourceId = 0; switch (mSearchType) { case Artist: resourceId = R.string.search_title_artists; break; case Album: resourceId = R.string.search_title_albums; break; case Playlist: resourceId = R.string.search_title_playlists; break; case Song: resourceId = R.string.search_title_songs; break; } actionBar.setTitle(getString(resourceId, mFilterString).toUpperCase()); actionBar.setDisplayHomeAsUpEnabled(true); // Set the prefix mAdapter.getUnderlyingAdapter().setPrefix(mFilterString); // Start the loader for the query getSupportLoaderManager().initLoader(SEARCH_LOADER, null, this); } else { mTopLevelSearch = true; mSearchHistoryCallback = new SearchHistoryCallback(); // Start the loader for the search history getSupportLoaderManager().initLoader(HISTORY_LOADER, null, mSearchHistoryCallback); } // set the background on the root view getWindow().getDecorView().getRootView() .setBackgroundColor(getResources().getColor(R.color.background_color)); }
From source file:com.bukanir.android.activities.MoviesListActivity.java
private void handleSearchIntent(Intent intent) { Log.d(TAG, "handleSearchIntent"); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); if (Utils.isNetworkAvailable(this)) { Log.d(TAG, "networkAvailable"); moviesTask = new MoviesTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { moviesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query, null); } else { moviesTask.execute(query, null); }//from w ww. j av a 2 s . c o m } else { Toast.makeText(this, getString(R.string.network_not_available), Toast.LENGTH_LONG).show(); } } }
From source file:free.yhc.netmbuddy.YTSearchActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent);//from ww w . j a v a2 s.c o m if (!Intent.ACTION_SEARCH.equals(intent.getAction())) return; // ignore unexpected intent final String query = intent.getStringExtra(SearchManager.QUERY); SearchSuggestionProvider.saveRecentQuery(query); disablePageIndexBar(); Utils.getUiHandler().post(new Runnable() { @Override public void run() { startNewSearch(query, query); } }); }
From source file:com.gimranov.zandy.app.ItemActivity.java
private Cursor prepareCursor() { Cursor cursor;/*from w w w .j a v a2 s. c om*/ // Be ready for a search Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { query = intent.getStringExtra(SearchManager.QUERY); cursor = getCursor(query); this.setTitle(getResources().getString(R.string.search_results, query)); } else if (query != null) { cursor = getCursor(query); this.setTitle(getResources().getString(R.string.search_results, query)); } else if (intent.getStringExtra("com.gimranov.zandy.app.tag") != null) { String tag = intent.getStringExtra("com.gimranov.zandy.app.tag"); Query q = new Query(); q.set("tag", tag); cursor = getCursor(q); this.setTitle(getResources().getString(R.string.tag_viewing_items, tag)); } else { collectionKey = intent.getStringExtra("com.gimranov.zandy.app.collectionKey"); ItemCollection coll; if (collectionKey != null && (coll = ItemCollection.load(collectionKey, db)) != null) { cursor = getCursor(coll); this.setTitle(coll.getTitle()); } else { cursor = getCursor(); this.setTitle(getResources().getString(R.string.all_items)); } } return cursor; }