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:org.fs.galleon.presenters.MainActivityPresenter.java
@Override public void handleSearch(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); Observable.just(query).flatMap(txt -> { SearchQueryValidator q = SearchQueryValidator.newInstance(); ValidationResult<String> valid = q.validate(txt, Locale.getDefault()); return Observable.just(valid); }).filter(ValidationResult::isValid).subscribe(isValid -> { if (!view.isProgressVisible()) { view.showProgress();//from w w w . j a v a2 s . c om } //creates if not previously initialized if there is any we need previous subscription to be canceled accordingly createIfUsecaseNotExists(isValid.value()); usecase.executeAsyncWidthDelay(new ISearchCustomersUseCase.Callback() { @Override public void onSuccess(Response<List<Customer>> response) { if (response.isSuccess()) { //we send it to our customer BusManager.send(new SearchFoundEvent(response.data())); } else { //show error log(Log.WARN, String.format(Locale.ENGLISH, "ErrorCode: %d\nErrorMessage: %s\n", response.code(), response.message())); view.showError(String.format(Locale.ENGLISH, "Error occured while executing.. '%s'", response.message())); } } @Override public void onError(Throwable thr) { log(thr); } @Override public void onCompleted() { view.hideProgress(); } }, QUERY_DELAY, TimeUnit.MILLISECONDS); }); } }
From source file:com.deliciousdroid.fragment.BrowseBookmarkFeedFragment.java
@Override public void onResume() { super.onResume(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); base.setTitle(getString(R.string.search_results_global_tag_title, query)); } else if (username.equals("recent")) { base.setTitle(getString(R.string.browse_recent_bookmarks_title)); } else if (username.equals("network")) { base.setTitle(getString(R.string.browse_network_bookmarks_title)); } else {//from w ww . j a v a 2 s . co m if (tagname != null && tagname != "") { base.setTitle(getString(R.string.browse_user_bookmarks_tagged_title, username, tagname)); } else { base.setTitle(getString(R.string.browse_user_bookmarks_title, username)); } } Uri data = base.getIntent().getData(); if (data != null && data.getUserInfo() != null && data.getUserInfo() != "") { username = data.getUserInfo(); } else if (base.getIntent().hasExtra("username")) { username = base.getIntent().getStringExtra("username"); } else username = base.mAccount.name; }
From source file:com.app_software.chromisstock.ProductListActivity.java
@Override public void onNewIntent(Intent intent) { //calls twice super.onNewIntent(intent); Log.v(TAG, "onNewIntent"); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String search = intent.getStringExtra(SearchManager.QUERY); Log.v(TAG, "Searching for: " + search); m_ListFragment.setSearch(search); }// w ww . j ava 2s .com }
From source file:com.android.calendar.SearchActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); dynamicTheme.onCreate(this); // This needs to be created before setContentView mController = CalendarController.getInstance(this); mHandler = new Handler(); mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda); setContentView(R.layout.search);/*from www .ja va 2s . c o m*/ setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); mContentResolver = getContentResolver(); if (mIsMultipane) { if (getSupportActionBar() != null) { getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); } } else { if (getSupportActionBar() != null) { getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME); } } // Must be the first to register because this activity can modify the // list of event handlers in it's handle method. This affects who the // rest of the handlers the controller dispatches to are. mController.registerEventHandler(HANDLER_KEY, this); mDeleteEventHelper = new DeleteEventHelper(this, this, false /* don't exit when done */); long millis = 0; if (icicle != null) { // Returns 0 if key not found millis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME); if (DEBUG) { Log.v(TAG, "Restore value from icicle: " + millis); } } if (millis == 0) { // Didn't find a time in the bundle, look in intent or current time millis = Utils.timeFromIntentInMillis(getIntent()); } Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query; if (icicle != null && icicle.containsKey(BUNDLE_KEY_RESTORE_SEARCH_QUERY)) { query = icicle.getString(BUNDLE_KEY_RESTORE_SEARCH_QUERY); } else { query = intent.getStringExtra(SearchManager.QUERY); } if ("TARDIS".equalsIgnoreCase(query)) { Utils.tardis(); } initFragments(millis, query); } }
From source file:com.googlecode.android_scripting.activity.ApiBrowser.java
@Override protected void onNewIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { searchResultMode = true;// www . j a va 2 s . c o m final String query = intent.getStringExtra(SearchManager.QUERY); // ((TextView) findViewById(R.id.left_text)).setText(query); updateAndFilterMethodDescriptors(query); if (mMethodDescriptors.size() == 1) { mExpandedPositions.add(0); } else { mExpandedPositions.clear(); } mAdapter.notifyDataSetChanged(); } }
From source file:org.bwgz.quotation.activity.SearchResultsActivity.java
@Override public void startActivity(Intent intent) { Log.d(TAG, String.format("startActivity - intent: %s", intent)); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { int type = getIntent().getIntExtra(EXTRA_SEARCH_TYPE, FreebaseSearch.SEARCH_TYPE_KEYWORD); intent.putExtra(SearchResultsActivity.EXTRA_SEARCH_TYPE, type); }//from ww w . j a va 2s . c o m super.startActivity(intent); }
From source file:org.melky.geekjuniorapp.GeekJunior.java
private void handleIntent(Intent intent) { if (Intent.ACTION_VIEW.equals(intent.getAction())) { final FragmentManager fragmentManager = getSupportFragmentManager(); int i = fragmentManager.getBackStackEntryCount(); // handles a click on a search suggestion; launches activity to show word Uri uri = intent.getData();//from www . j a v a 2s .co m Cursor cursor = managedQuery(uri, null, null, null, null); cursor.moveToFirst(); int wIndex = cursor.getColumnIndexOrThrow(GeekDictionaryDatabase.KEY_WORD); int dIndex = cursor.getColumnIndexOrThrow(GeekDictionaryDatabase.KEY_DEFINITION); //Toast.makeText(this,cursor.getString(wIndex)+"--"+cursor.getString(dIndex),Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.ph_buscar, Toast.LENGTH_SHORT).show(); searchView.setQuery(cursor.getString(dIndex), true); getJsonToFragment(cursor.getString(dIndex), "tag"); if (i == 0) { getSupportFragmentManager().beginTransaction().replace(R.id.container, new PlaceholderFragment(17)) .addToBackStack("PlaceholderFragment").commit(); } else { getSupportFragmentManager().beginTransaction().replace(R.id.container, new PlaceholderFragment(17)) .addToBackStack("PlaceholderFragment2").commit(); } } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { // handles a search query String query = intent.getStringExtra(SearchManager.QUERY); //do-nothing } }
From source file:org.voidsink.anewjkuapp.fragment.MapFragment.java
@Override public void handlePendingIntent(Intent intent) { super.handlePendingIntent(intent); if (intent != null) { if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.getData() != null) { finishSearch(intent.getData()); } else { String query = intent.getStringExtra(SearchManager.QUERY); boolean isExactLocation = intent.getBooleanExtra(MainActivity.ARG_EXACT_LOCATION, false); doSearch(query, isExactLocation); }//from ww w.j a v a 2 s . c o m } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.getData() != null) { finishSearch(intent.getData()); } else { String query = intent.getStringExtra(SearchManager.QUERY); boolean isExactLocation = intent.getBooleanExtra(MainActivity.ARG_EXACT_LOCATION, false); doSearch(query, isExactLocation); } } } }
From source file:com.qubling.sidekick.ui.module.ModuleSearchActivity.java
/** Called when the activity is first created. */ @Override/*from w w w .j ava 2 s . c o m*/ protected void onCreate(Bundle state) { super.onCreate(state); // Setup the view setContentView(R.layout.module_search); // Setup BugSense Util.setupBugSense(this); // Initialize the fragment, if on a tablet if (isTwoPanelView()) { boolean showingModuleViewer = state != null && state.getBoolean("showingModuleViewer"); Fragment viewFragment; if (showingModuleViewer) { viewFragment = new ModuleViewFragment(); } else { viewFragment = new ModuleViewPlaceholderFragment(); } if (state == null) getSupportFragmentManager().beginTransaction() .add(R.id.module_view_fragment_container, viewFragment).commit(); } // Check to see if we got a search Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); getModuleSearchFragment().doNewSearch(query); } moduleSearchHelper.onCreate(state); new ConnectivityCheck(this); // AccountManager am = AccountManager.get(this); // Account[] accounts = am.getAccounts(); // for (Account account : accounts) { // Log.d("ModuleSearchActivity", "ACCOUNT " + account.name + ", " + account.type); // } }
From source file:com.cuddlesoft.nori.SearchActivity.java
/** * Set up the action bar SearchView and its event handlers. * * @param menu Menu after being inflated in {@link #onCreateOptionsMenu(android.view.Menu)}. *//*from ww w.j a v a 2s . c o m*/ private void setUpSearchView(Menu menu) { // Extract SearchView from the MenuItem object. searchMenuItem = menu.findItem(R.id.action_search); searchMenuItem.setVisible(searchClientSettings != null); searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); // Set Searchable XML configuration. SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // Set SearchView attributes. searchView.setFocusable(false); searchView.setQueryRefinementEnabled(true); // Set SearchView event listeners. searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (searchClientSettings != null) { // Prepare a intent to send to a new instance of this activity. Intent intent = new Intent(SearchActivity.this, SearchActivity.class); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(BUNDLE_ID_SEARCH_CLIENT_SETTINGS, searchClientSettings); intent.putExtra(BUNDLE_ID_SEARCH_QUERY, query); // Collapse the ActionView. This makes navigating through previous results using the back key less painful. MenuItemCompat.collapseActionView(searchMenuItem); // Start a new activity with the created Intent. startActivity(intent); } // Returns true to override the default behaviour and stop another search Intent from being sent. return true; } @Override public boolean onQueryTextChange(String newText) { // Returns false to perform the default action. return false; } }); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return onSuggestionClick(position); } @Override public boolean onSuggestionClick(int position) { if (searchClientSettings != null) { // Get the SearchView's suggestion adapter. CursorAdapter adapter = searchView.getSuggestionsAdapter(); // Get the suggestion at given position. Cursor c = adapter.getCursor(); c.moveToPosition(position); // Create and send a search intent. Intent intent = new Intent(SearchActivity.this, SearchActivity.class); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(BUNDLE_ID_SEARCH_CLIENT_SETTINGS, searchClientSettings); intent.putExtra(BUNDLE_ID_SEARCH_QUERY, c.getString(c.getColumnIndex(SearchSuggestionDatabase.COLUMN_NAME))); startActivity(intent); // Release native resources. c.close(); } // Return true to override default behaviour and prevent another intent from being sent. return true; } }); if (savedInstanceState != null) { // Restore state from saved instance state bundle (after screen rotation, app restored from background, etc.) if (savedInstanceState.containsKey(BUNDLE_ID_SEARCH_QUERY)) { // Restore search query from saved instance state. searchView.setQuery(savedInstanceState.getCharSequence(BUNDLE_ID_SEARCH_QUERY), false); } // Restore iconified/expanded search view state from saved instance state. if (savedInstanceState.getBoolean(BUNDLE_ID_SEARCH_VIEW_IS_EXPANDED, false)) { MenuItemCompat.expandActionView(searchMenuItem); // Restore focus state. if (!savedInstanceState.getBoolean(BUNDLE_ID_SEARCH_VIEW_IS_FOCUSED, false)) { searchView.clearFocus(); } } } else if (getIntent() != null && getIntent().getAction().equals(Intent.ACTION_SEARCH)) { // Set SearchView query string to match the one sent in the SearchIntent. searchView.setQuery(getIntent().getStringExtra(BUNDLE_ID_SEARCH_QUERY), false); } }