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:net.eledge.android.europeana.gui.activity.SearchActivity.java
private void handleIntent(Intent intent) { String query = null;/* w w w . ja v a 2 s. com*/ String[] qf = null; if (intent != null) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { query = intent.getStringExtra(SearchManager.QUERY); qf = splitFacets(intent.getStringExtra(SearchManager.USER_QUERY)); } else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { Parcelable[] parcelables = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage msg = (NdefMessage) parcelables[0]; Uri uri = Uri.parse(new String(msg.getRecords()[0].getPayload())); query = uri.getQueryParameter("query"); qf = StringArrayUtils.toArray(uri.getQueryParameters("qf")); } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { query = intent.getDataString(); if (!TextUtils.isEmpty(query)) { if (StringUtils.contains(query, "europeana.eu/")) { Uri uri = Uri.parse(query); query = uri.getQueryParameter("query"); qf = StringArrayUtils.toArray(uri.getQueryParameters("qf")); } } } else { // no search action recognized? end this activity... closeSearchActivity(); } if (!TextUtils.isEmpty(query) && !TextUtils.equals(runningSearch, query)) { runningSearch = query; if (StringArrayUtils.isNotBlank(qf)) { searchController.newSearch(this, query, qf); } else { searchController.newSearch(this, query); } getSupportActionBar().setTitle(searchController.getSearchTitle(this)); } } }
From source file:com.tt.jobtracker.MainActivity.java
private void handleIntent(Intent intent) { setContentView(R.layout.activity_main); SetNavigationDrawer();// w w w. j ava2s .c o m if (Intent.ACTION_SEARCH.equals(intent.getAction())) { SearchText = intent.getStringExtra(SearchManager.QUERY); } else { SearchText = ""; } }
From source file:io.github.tjg1.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)}. *///w w w. ja va2 s. co 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 submit action and allow empty queries. SearchView.SearchAutoComplete searchTextView = (SearchView.SearchAutoComplete) searchView .findViewById(R.id.search_src_text); searchTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { CharSequence query = textView.getText(); if (query != null && 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.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(BUNDLE_ID_SEARCH_CLIENT_SETTINGS, searchClientSettings); intent.putExtra(BUNDLE_ID_SEARCH_QUERY, query.toString()); // 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; } }); 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.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 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); } }
From source file:net.reichholf.dreamdroid.activities.ServiceListActivity.java
/** * @param title//from w w w . j a v a2 s . c o m * The program title to find similar programs for */ public void openSimilar(String title) { Log.e("dreamDroid", "title: " + title); Intent intent = new Intent(this, SearchEpgActivity.class); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, title); startActivity(intent); }
From source file:com.necisstudio.highlightgoal.MainActivity.java
@Override protected void onNewIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); searchview.setQuery(query, false); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); iddrawer = 20;/* w w w .ja va2 s .co m*/ imgLogo.setImageResource(0); txtTitle.setText(searchview.getQuery().toString()); fList = new ArrayList<Fragment>(); List<Fragment> fragments = getFragments( HighlightLatestFragment.newInstance(searchview.getQuery().toString()), KlasementLigaFragment.newInstance("inggris"), ScheduleLigaLatestFragment.newInstance(searchview.getQuery().toString())); adapter_viewPager = new Adapter_ViewPager(getSupportFragmentManager(), fragments); final ViewPager pager = (ViewPager) findViewById(R.id.viewpager); tabHost = (TabLayout) findViewById(R.id.materialTabHost); pager.setAdapter(adapter_viewPager); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); tabHost.setupWithViewPager(pager); tabHost.getTabAt(0).setText("Highlight"); tabHost.getTabAt(1).setText("Schedule"); } }
From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java
@Override protected void onNewIntent(Intent intent) { // The user has probably entered a URL into "Go" String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action)) { if (mIsFiltering) { String filterText = intent.getStringExtra(SearchManager.QUERY); mFilterView.doFilter(filterText); }//from w w w . jav a 2 s . co m } }
From source file:com.dycody.android.idealnote.ListFragment.java
@SuppressWarnings("static-access") @Override/*from w w w.java 2s . com*/ public void onResume() { super.onResume(); if (Intent.ACTION_SEARCH.equals(mainActivity.getIntent().getAction())) { initNotesList(mainActivity.getIntent()); } }
From source file:io.radio.streamer.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from w ww. ja v a2 s .c o m*/ // Handle action buttons switch (item.getItemId()) { case R.id.action_search: // create intent to search Intent intent = new Intent(Intent.ACTION_SEARCH); // catch event that there's no activity to handle intent if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Toast.makeText(this, R.string.search_not_available, Toast.LENGTH_LONG).show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.klinker.android.twitter.activities.search.SearchPager.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); overridePendingTransition(0, 0);//from ww w. java 2 s . c o m finish(); Intent restart = new Intent(context, SearchPager.class); restart.putExtra(SearchManager.QUERY, searchQuery); restart.setAction(Intent.ACTION_SEARCH); restart.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); overridePendingTransition(0, 0); startActivity(restart); }
From source file:aarddict.android.ArticleViewActivity.java
@Override public boolean onSearchRequested() { Intent intent = getIntent();//from ww w . j ava 2s .c o m String action = intent == null ? null : intent.getAction(); if (action != null) { String word = null; if (action.equals(Intent.ACTION_SEARCH)) { word = intent.getStringExtra("query"); } else if (action.equals(Intent.ACTION_SEND)) { word = intent.getStringExtra(Intent.EXTRA_TEXT); } if (word != null) { Intent next = new Intent(); next.setClass(this, LookupActivity.class); next.setAction(Intent.ACTION_SEARCH); next.putExtra(SearchManager.QUERY, word); startActivity(next); } } finish(); return true; }