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.dycody.android.idealnote.ListFragment.java
/** * Notes list adapter initialization and association to view *//*from w w w. ja v a2 s. c o m*/ void initNotesList(Intent intent) { Log.d(Constants.TAG, "initNotesList intent: " + intent.getAction()); progress_wheel.setAlpha(1); list.setAlpha(0); // Search for a tag // A workaround to simplify it's to simulate normal search if (Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_BROWSABLE)) { searchTags = intent.getDataString().replace(UrlCompleter.HASHTAG_SCHEME, ""); goBackOnToggleSearchLabel = true; } // Searching searchQuery = searchQueryInstant; searchQueryInstant = null; if (searchTags != null || searchQuery != null || Intent.ACTION_SEARCH.equals(intent.getAction())) { // Using tags if (searchTags != null && intent.getStringExtra(SearchManager.QUERY) == null) { searchQuery = searchTags; NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByTag", searchQuery); } else { // Get the intent, verify the action and get the query if (intent.getStringExtra(SearchManager.QUERY) != null) { searchQuery = intent.getStringExtra(SearchManager.QUERY); searchTags = null; } NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByPattern", searchQuery); } toggleSearchLabel(true); } else { // Check if is launched from a widget with categories if ((Constants.ACTION_WIDGET_SHOW_LIST.equals(intent.getAction()) && intent.hasExtra(Constants.INTENT_WIDGET)) || !TextUtils.isEmpty(mainActivity.navigationTmp)) { String widgetId = intent.hasExtra(Constants.INTENT_WIDGET) ? intent.getExtras().get(Constants.INTENT_WIDGET).toString() : null; if (widgetId != null) { String sqlCondition = prefs.getString(Constants.PREF_WIDGET_PREFIX + widgetId, ""); String categoryId = TextHelper.checkIntentCategory(sqlCondition); mainActivity.navigationTmp = !TextUtils.isEmpty(categoryId) ? categoryId : null; } intent.removeExtra(Constants.INTENT_WIDGET); if (mainActivity.navigationTmp != null) { Long categoryId = Long.parseLong(mainActivity.navigationTmp); NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getNotesByCategory", categoryId); } else { NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes", true); } } else { NoteLoaderTask.getInstance().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "getAllNotes", true); } } }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
/** * Returns true if the Intent was "Handled" * @param intent Input Intent/*from w ww . jav a 2s. c om*/ */ public boolean handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { OpenPath searchIn = new OpenFile("/"); Bundle bundle = intent.getBundleExtra(SearchManager.APP_DATA); if (bundle != null && bundle.containsKey("path")) try { searchIn = FileManager.getOpenCache(bundle.getString("path"), false, null); } catch (IOException e) { searchIn = new OpenFile(bundle.getString("path")); } String query = intent.getStringExtra(SearchManager.QUERY); Logger.LogDebug("ACTION_SEARCH for \"" + query + "\" in " + searchIn); SearchResultsFragment srf = SearchResultsFragment.getInstance(searchIn, query); if (mViewPagerEnabled && mViewPagerAdapter != null) { mViewPagerAdapter.add(srf); setViewPageAdapter(mViewPagerAdapter, true); setCurrentItem(mViewPagerAdapter.getCount() - 1, true); } else { getSupportFragmentManager().beginTransaction().replace(R.id.content_frag, srf).commit(); } } else if ((Intent.ACTION_VIEW.equals(intent.getAction()) || Intent.ACTION_EDIT.equals(intent.getAction())) && intent.getData() != null) { OpenPath path = FileManager.getOpenCache(intent.getDataString(), this); if (editFile(path)) return true; } else if (intent.hasExtra("state")) { Bundle state = intent.getBundleExtra("state"); onRestoreInstanceState(state); } return false; }
From source file:com.delexus.imitationzhihu.MySearchView.java
void launchQuerySearch(int actionKey, String actionMsg, String query) { String action = Intent.ACTION_SEARCH; Intent intent = createIntent(action, null, null, query, actionKey, actionMsg); getContext().startActivity(intent);/*from ww w . j a v a2 s . co m*/ }
From source file:com.tct.mail.ui.AbstractActivityController.java
/** * Initialize the action bar. This is not visible to OnePaneController and * TwoPaneController so they cannot override this behavior. *//*w w w . j ava2 s . c om*/ protected void initializeActionBar() { final ActionBar actionBar = mActivity.getSupportActionBar(); if (actionBar == null) { return; } Intent intent = mActivity.getIntent(); /// TCT: Action is search but no extra account means a global search final boolean isSearch = intent != null && Intent.ACTION_SEARCH.equals(intent.getAction()) && intent.hasExtra(Utils.EXTRA_ACCOUNT); mActionBarController = isSearch ? new SearchActionBarController(mContext) : new ActionBarController(mContext); mActionBarController.initialize(mActivity, this, actionBar); // init the action bar to allow the 'up' affordance. // any configurations that disallow 'up' should do that later. mActionBarController.setBackButton(); }
From source file:com.todotxt.todotxttouch.TodoTxtTouch.java
/** Handle clear filter click **/ public void onClearClick(View v) { clearFilter();// w w w .java2 s .c o m // End current activity if it's search results Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { finish(); } else { // otherwise just clear the filter in the current activity setFilteredTasks(false); } }
From source file:com.delexus.imitationzhihu.MySearchView.java
/** * Create and return an Intent that can launch the voice search activity, perform a specific * voice transcription, and forward the results to the searchable activity. * * @param baseIntent The voice app search intent to start from * @return A completely-configured intent ready to send to the voice search activity *///from ww w.j a va 2 s .c o m private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) { ComponentName searchActivity = searchable.getSearchActivity(); // create the necessary intent to set up a search-and-forward operation // in the voice search system. We have to keep the bundle separate, // because it becomes immutable once it enters the PendingIntent Intent queryIntent = new Intent(Intent.ACTION_SEARCH); queryIntent.setComponent(searchActivity); PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent, PendingIntent.FLAG_ONE_SHOT); // Now set up the bundle that will be inserted into the pending intent // when it's time to do the search. We always build it here (even if empty) // because the voice search activity will always need to insert "QUERY" into // it anyway. Bundle queryExtras = new Bundle(); if (mAppSearchData != null) { queryExtras.putParcelable(SearchManager.APP_DATA, mAppSearchData); } // Now build the intent to launch the voice search. Add all necessary // extras to launch the voice recognizer, and then all the necessary extras // to forward the results to the searchable activity Intent voiceIntent = new Intent(baseIntent); // Add all of the configuration options supplied by the searchable's metadata String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM; String prompt = null; String language = null; int maxResults = 1; Resources resources = getResources(); if (searchable.getVoiceLanguageModeId() != 0) { languageModel = resources.getString(searchable.getVoiceLanguageModeId()); } if (searchable.getVoicePromptTextId() != 0) { prompt = resources.getString(searchable.getVoicePromptTextId()); } if (searchable.getVoiceLanguageId() != 0) { language = resources.getString(searchable.getVoiceLanguageId()); } if (searchable.getVoiceMaxResults() != 0) { maxResults = searchable.getVoiceMaxResults(); } voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel); voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt); voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults); voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null : searchActivity.flattenToShortString()); // Add the values that configure forwarding the results voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending); voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras); return voiceIntent; }
From source file:org.mixare.MixViewActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { intent.setClass(this, MarkerListActivity.class); startActivity(intent);//from ww w . java 2 s. c om } }
From source file:com.lgallardo.qbittorrentclient.RefreshListener.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { // Use the query to search your data somehow searchField = intent.getStringExtra(SearchManager.QUERY); // Log.d("Debug", "Search for..." + searchField); // Autorefresh refreshSwipeLayout();/*from w w w .j a va 2 s . com*/ refreshCurrent(); } if (Intent.ACTION_VIEW.equals(intent.getAction())) { // Add torrent (file, url or magnet) addTorrentByIntent(intent); // // Activity is visible activityIsVisible = true; // Autorefresh refreshCurrent(); } try { if (intent.getStringExtra("from").equals("NotifierService")) { saveLastState("completed"); setSelectionAndTitle("completed"); refresh("completed", currentLabel); } if (intent.getStringExtra("from").equals("RSSItemActivity")) { // Add torrent (file, url or magnet) addTorrentByIntent(intent); // // Activity is visble activityIsVisible = true; // Autorefresh refreshCurrent(); } // Log.d("Debug", "lastState (handle intent):End " ); } catch (Exception e) { // Log.e("Debug", "Handle intent: " + e.toString() ); } }
From source file:android.support.v7.widget.SearchView.java
private void launchQuerySearch(int actionKey, String actionMsg, String query) { String action = Intent.ACTION_SEARCH; Intent intent = createIntent(action, null, null, query, actionKey, actionMsg); getContext().startActivity(intent);//from w w w . java2s .co m }
From source file:io.github.vomitcuddle.SearchViewAllowEmpty.SearchView.java
/** * Create and return an Intent that can launch the voice search activity, perform a specific * voice transcription, and forward the results to the searchable activity. * * @param baseIntent The voice app search intent to start from * @return A completely-configured intent ready to send to the voice search activity *///from w w w. j a va 2s . c o m private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) { ComponentName searchActivity = searchable.getSearchActivity(); // create the necessary intent to set up a search-and-forward operation // in the voice search system. We have to keep the bundle separate, // because it becomes immutable once it enters the PendingIntent Intent queryIntent = new Intent(Intent.ACTION_SEARCH); queryIntent.setComponent(searchActivity); PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent, PendingIntent.FLAG_ONE_SHOT); // Now set up the bundle that will be inserted into the pending intent // when it's time to do the search. We always build it here (even if empty) // because the voice search activity will always need to insert "QUERY" into // it anyway. Bundle queryExtras = new Bundle(); if (mAppSearchData != null) { queryExtras.putParcelable(SearchManager.APP_DATA, mAppSearchData); } // Now build the intent to launch the voice search. Add all necessary // extras to launch the voice recognizer, and then all the necessary extras // to forward the results to the searchable activity Intent voiceIntent = new Intent(baseIntent); // Add all of the configuration options supplied by the searchable's metadata String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM; String prompt = null; String language = null; int maxResults = 1; Resources resources = getResources(); if (searchable.getVoiceLanguageModeId() != 0) { languageModel = resources.getString(searchable.getVoiceLanguageModeId()); } if (searchable.getVoicePromptTextId() != 0) { prompt = resources.getString(searchable.getVoicePromptTextId()); } if (searchable.getVoiceLanguageId() != 0) { language = resources.getString(searchable.getVoiceLanguageId()); } if (searchable.getVoiceMaxResults() != 0) { maxResults = searchable.getVoiceMaxResults(); } voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel); voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt); voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults); voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null : searchActivity.flattenToShortString()); // Add the values that configure forwarding the results voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending); voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras); return voiceIntent; }