List of usage examples for android.content Intent ACTION_SEARCH
String ACTION_SEARCH
To view the source code for android.content Intent ACTION_SEARCH.
Click Source Link
From source file:com.ronnyml.sweetplayer.ui.MainActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String search_text = intent.getStringExtra(SearchManager.QUERY); if (search_text.equals("") || search_text.length() == 0) { Utils.showUserMessage(mActivity.getApplicationContext(), getString(R.string.search_text_empty)); } else {/*from ww w. ja va 2 s . c o m*/ Intent newIntent = new Intent(mActivity.getApplicationContext(), MainActivity.class); newIntent.putExtra(Constants.IS_SEARCH, true); newIntent.putExtra(Constants.SEARCH_TEXT, search_text); mActivity.startActivity(newIntent); } Utils.LogD("Main", search_text); } }
From source file:com.numenta.taurus.instance.InstanceListActivity.java
/** * If the activity was started with an intent, such as {@link Intent#ACTION_SEARCH}, * perform the action expressed in the intent. * * @param intent The intent to process// www . ja v a2s. c o m * @see Intent#ACTION_SEARCH */ private void handleIntent(@NonNull Intent intent) { // Handle "Search" intents if (Intent.ACTION_SEARCH.equals(intent.getAction())) { // SearchManager.QUERY is the key that a SearchManager will use to send a query string // to an Activity. String query = intent.getStringExtra(SearchManager.QUERY); _listFragment.applyFilter(query); } if (TaurusApplication.ACTION_SHOW_NOTIFICATION_LIST.equals(intent.getAction())) { clearNotifications(); if (_favorites.getCheckedRadioButtonId() == R.id.filter_none) { RadioButton b = (RadioButton) _favorites.findViewById(R.id.filter_favorites); b.setChecked(true); } } }
From source file:com.ibm.commerce.worklight.android.search.SearchSuggestionsProvider.java
/** * Creates the search result row/*from www. java2 s . c o m*/ * @param id * @param suggestWord * @param icon * @return */ private Object[] createRow(Integer id, String suggestWord, int icon) { return new Object[] { id, suggestWord, icon, suggestWord, Intent.ACTION_SEARCH, SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT }; }
From source file:com.jtechme.apphub.FDroid.java
private void handleSearchOrAppViewIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); performSearch(query);//from ww w.ja v a2 s. c o m return; } final Uri data = intent.getData(); if (data == null) { return; } final String scheme = data.getScheme(); final String path = data.getPath(); String packageName = null; String query = null; if (data.isHierarchical()) { final String host = data.getHost(); if (host == null) { return; } switch (host) { case "f-droid.org": if (path.startsWith("/repository/browse")) { // http://f-droid.org/repository/browse?fdfilter=search+query query = UriCompat.getQueryParameter(data, "fdfilter"); // http://f-droid.org/repository/browse?fdid=packageName packageName = UriCompat.getQueryParameter(data, "fdid"); } else if (path.startsWith("/app")) { // http://f-droid.org/app/packageName packageName = data.getLastPathSegment(); if ("app".equals(packageName)) { packageName = null; } } break; case "details": // market://details?id=app.id packageName = UriCompat.getQueryParameter(data, "id"); break; case "search": // market://search?q=query query = UriCompat.getQueryParameter(data, "q"); break; case "play.google.com": if (path.startsWith("/store/apps/details")) { // http://play.google.com/store/apps/details?id=app.id packageName = UriCompat.getQueryParameter(data, "id"); } else if (path.startsWith("/store/search")) { // http://play.google.com/store/search?q=foo query = UriCompat.getQueryParameter(data, "q"); } break; case "apps": case "amazon.com": case "www.amazon.com": // amzn://apps/android?p=app.id // http://amazon.com/gp/mas/dl/android?s=app.id packageName = UriCompat.getQueryParameter(data, "p"); query = UriCompat.getQueryParameter(data, "s"); break; } } else if ("fdroid.app".equals(scheme)) { // fdroid.app:app.id packageName = data.getSchemeSpecificPart(); } else if ("fdroid.search".equals(scheme)) { // fdroid.search:query query = data.getSchemeSpecificPart(); } if (!TextUtils.isEmpty(query)) { // an old format for querying via packageName if (query.startsWith("pname:")) packageName = query.split(":")[1]; // sometimes, search URLs include pub: or other things before the query string if (query.contains(":")) query = query.split(":")[1]; } if (!TextUtils.isEmpty(packageName)) { Utils.debugLog(TAG, "FDroid launched via app link for '" + packageName + "'"); Intent intentToInvoke = new Intent(this, AppDetails.class); intentToInvoke.putExtra(AppDetails.EXTRA_APPID, packageName); startActivity(intentToInvoke); } else if (!TextUtils.isEmpty(query)) { Utils.debugLog(TAG, "FDroid launched via search link for '" + query + "'"); performSearch(query); } }
From source file:com.klinker.android.twitter.activities.search.SearchPager.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { searchQuery = intent.getStringExtra(SearchManager.QUERY); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE); if (searchQuery.contains("#")) { suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null); } else {/* www. j a v a 2s .c o m*/ suggestions.saveRecentQuery(searchQuery, null); } searchQuery += " -RT"; } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri uri = intent.getData(); String uriString = uri.toString(); if (uriString.contains("status/")) { long id; String replace = uriString.substring(uriString.indexOf("status")).replace("status/", "") .replaceAll("photo/*", ""); if (replace.contains("/")) { replace = replace.substring(0, replace.indexOf("/")); } else if (replace.contains("?")) { replace = replace.substring(0, replace.indexOf("?")); } try { id = Long.parseLong(replace); } catch (Exception e) { id = 0l; } searchQuery = id + ""; onlyStatus = true; } else if (!uriString.contains("q=") && !uriString.contains("screen_name%3D")) { // going to try searching for users i guess String name = uriString.substring(uriString.indexOf(".com/")); name = name.replaceAll("/", "").replaceAll(".com", ""); searchQuery = name; onlyProfile = true; } else if (uriString.contains("q=")) { try { String search = uri.getQueryParameter("q"); if (search != null) { searchQuery = search; SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE); if (searchQuery.contains("#")) { suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null); } else { suggestions.saveRecentQuery(searchQuery, null); } searchQuery += " -RT"; } else { searchQuery = ""; } } catch (Exception e) { } } else { try { String search = uriString; search = search.substring(search.indexOf("screen_name%3D") + 14); search = search.substring(0, search.indexOf("%")); if (search != null) { searchQuery = search; SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE); if (searchQuery.contains("#")) { suggestions.saveRecentQuery(searchQuery.replaceAll("\"", ""), null); } else { suggestions.saveRecentQuery(searchQuery, null); } searchQuery += " -RT"; } else { searchQuery = ""; } onlyProfile = true; } catch (Exception e) { } } } }
From source file:com.klinker.android.twitter.ui.search.SearchPager.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { searchQuery = intent.getStringExtra(SearchManager.QUERY); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE); suggestions.saveRecentQuery(searchQuery, null); } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri uri = intent.getData();// w ww . j av a 2s .com String uriString = uri.toString(); if (uriString.contains("status/")) { long id; String replace = uriString.substring(uriString.indexOf("status")).replace("status/", "") .replaceAll("photo/*", ""); if (replace.contains("/")) { replace = replace.substring(0, replace.indexOf("/")); } else if (replace.contains("?")) { replace = replace.substring(0, replace.indexOf("?")); } try { id = Long.parseLong(replace); } catch (Exception e) { id = 0l; } searchQuery = id + ""; onlyStatus = true; } else if (!uriString.contains("q=") && !uriString.contains("screen_name%3D")) { // going to try searching for users i guess String name = uriString.substring(uriString.indexOf(".com/")); name = name.replaceAll("/", "").replaceAll(".com", ""); searchQuery = name; onlyProfile = true; Log.v("talon_searching", "only profile"); } else if (uriString.contains("q=")) { try { String search = uri.getQueryParameter("q"); if (search != null) { searchQuery = search; SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE); suggestions.saveRecentQuery(searchQuery, null); } else { searchQuery = ""; } } catch (Exception e) { } } else { try { String search = uriString; search = search.substring(search.indexOf("screen_name%3D") + 14); search = search.substring(0, search.indexOf("%")); if (search != null) { searchQuery = search; SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE); suggestions.saveRecentQuery(searchQuery, null); } else { searchQuery = ""; } onlyProfile = true; } catch (Exception e) { } } } }
From source file:com.google.android.demos.atom.app.FeedActivity.java
@Override protected void onNewIntent(Intent intent) { // This method is called when the search interface is used to specify a // different feed URL. The same activity instance is reused, so it needs // to be updated to show a different feed. You don't need to worry about // implementing this method unless you have set launchMode="singleTop". setIntent(intent);/* w w w. java 2s . co m*/ String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action)) { String feedUrl = intent.getStringExtra(SearchManager.QUERY); if (Feeds.isValidFeedUrl(feedUrl)) { // Save this feed URL in the preferences, so that it will be // opened the next time the application is started. SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(PREFERENCE_FEED, feedUrl); editor.commit(); } else { mInvalidUrl = feedUrl; showDialog(DIALOG_INVALID_URL); } } reload(); }
From source file:org.fdroid.fdroid.FDroid.java
private void handleSearchOrAppViewIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); performSearch(query);// w w w .j a v a 2 s . c om return; } final Uri data = intent.getData(); if (data == null) { return; } final String scheme = data.getScheme(); final String path = data.getPath(); String packageName = null; String query = null; if (data.isHierarchical()) { final String host = data.getHost(); if (host == null) { return; } switch (host) { case "f-droid.org": if (path.startsWith("/repository/browse")) { // http://f-droid.org/repository/browse?fdfilter=search+query query = UriCompat.getQueryParameter(data, "fdfilter"); // http://f-droid.org/repository/browse?fdid=packageName packageName = UriCompat.getQueryParameter(data, "fdid"); } else if (path.startsWith("/app")) { // http://f-droid.org/app/packageName packageName = data.getLastPathSegment(); if ("app".equals(packageName)) { packageName = null; } } break; case "details": // market://details?id=app.id packageName = UriCompat.getQueryParameter(data, "id"); break; case "search": // market://search?q=query query = UriCompat.getQueryParameter(data, "q"); break; case "play.google.com": if (path.startsWith("/store/apps/details")) { // http://play.google.com/store/apps/details?id=app.id packageName = UriCompat.getQueryParameter(data, "id"); } else if (path.startsWith("/store/search")) { // http://play.google.com/store/search?q=foo query = UriCompat.getQueryParameter(data, "q"); } break; case "apps": case "amazon.com": case "www.amazon.com": // amzn://apps/android?p=app.id // http://amazon.com/gp/mas/dl/android?s=app.id packageName = UriCompat.getQueryParameter(data, "p"); query = UriCompat.getQueryParameter(data, "s"); break; } } else if ("fdroid.app".equals(scheme)) { // fdroid.app:app.id packageName = data.getSchemeSpecificPart(); } else if ("fdroid.search".equals(scheme)) { // fdroid.search:query query = data.getSchemeSpecificPart(); } if (!TextUtils.isEmpty(query)) { // an old format for querying via packageName if (query.startsWith("pname:")) { packageName = query.split(":")[1]; } // sometimes, search URLs include pub: or other things before the query string if (query.contains(":")) { query = query.split(":")[1]; } } if (!TextUtils.isEmpty(packageName)) { Utils.debugLog(TAG, "FDroid launched via app link for '" + packageName + "'"); Intent intentToInvoke = new Intent(this, AppDetails.class); intentToInvoke.putExtra(AppDetails.EXTRA_APPID, packageName); startActivity(intentToInvoke); finish(); } else if (!TextUtils.isEmpty(query)) { Utils.debugLog(TAG, "FDroid launched via search link for '" + query + "'"); performSearch(query); } }
From source file:com.vnapnic.streamgames.ui.TDActivity.java
@Override protected void onNewIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { setTitle(R.string.search_title); String query = intent.getStringExtra(SearchManager.QUERY); if (searchFragment == null) { searchFragment = new SearchFragment(); }//from www . j a va 2 s . c o m searchFragment.setQuery(query); searchFragment.loadData(); replaceFragment(searchFragment); } }
From source file:com.pindroid.fragment.BrowseBookmarkFeedFragment.java
@Override public void onResume() { super.onResume(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); getActivity().setTitle(getString(R.string.search_results_global_tag_title, query)); } else if (feed != null && feed.equals("recent")) { getActivity().setTitle(getString(R.string.browse_recent_bookmarks_title)); } else if (feed != null && feed.equals("popular")) { getActivity().setTitle(getString(R.string.browse_popular_bookmarks_title)); } else if (feed != null && feed.equals("network")) { getActivity().setTitle(getString(R.string.browse_network_bookmarks_title)); } else {//from w w w. java 2 s. c om if (tagname != null && tagname != "") { getActivity().setTitle(getString(R.string.browse_user_bookmarks_tagged_title, feed, tagname)); } else { getActivity().setTitle(getString(R.string.browse_user_bookmarks_title, feed)); } } }