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.nononsenseapps.notepad.MainActivity.java
@Override protected void onNewIntent(Intent intent) { // Search/* ww w.j a v a 2 s . com*/ if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); // list.onQueryTextChange(query); NotesListFragment list = getLeftFragment(); if (list != null && list.mSearchView != null) { list.mSearchView.setQuery(query, false); } else if (list != null) { list.onQueryTextSubmit(query); } // Edit or View a list or a note. } else if (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())) { handleEditIntent(intent); } else if (Intent.ACTION_INSERT.equals(intent.getAction())) { handleInsertIntent(intent); } else if (Intent.ACTION_SEND.equals(intent.getAction())) { handleInsertIntent(intent); } else if (getString(R.string.complete_note_broadcast_intent).equals(intent.getAction())) { // Sent from lock-screen widget on 4.2 and above. // Send complete broadcast and finish long noteId = NotesEditorFragment.getIdFromUri(intent.getData()); // This will complete the note if (noteId > -1) { Intent bintent = new Intent(this, NotePadBroadcastReceiver.class); bintent.setAction(getString(R.string.complete_note_broadcast_intent)); bintent.putExtra(NotePad.Notes._ID, noteId); Log.d(TAG, "Sending complete broadcast"); sendBroadcast(bintent); openNoteFragment(intent); // Toast.makeText(this, getString(R.string.completed), // Toast.LENGTH_SHORT).show(); } } else { // Open a note if (noteIdToSelect > -1 && currentContent == CONTENTVIEW.DUAL) { Bundle arguments = new Bundle(); arguments.putLong(NotesEditorFragment.KEYID, noteIdToSelect); NotesEditorFragment fragment = new NotesEditorFragment(); fragment.setArguments(arguments); getFragmentManager().beginTransaction().replace(R.id.rightFragment, fragment).commit(); noteIdToSelect = -1; } } }
From source file:com.brandroidtools.filemanager.activities.NavigationActivity.java
/** * Method that verifies the intent passed to the activity, and checks * if a request is made like Search.// w ww .ja va 2 s . c om * * @param intent The intent to check * @hide */ void checkIntent(Intent intent) { //Search action if (Intent.ACTION_SEARCH.equals(intent.getAction())) { Intent searchIntent = new Intent(this, SearchActivity.class); searchIntent.setAction(Intent.ACTION_SEARCH); //- SearchActivity.EXTRA_SEARCH_DIRECTORY searchIntent.putExtra(SearchActivity.EXTRA_SEARCH_DIRECTORY, getCurrentNavigationFragment().getCurrentDir()); //- SearchManager.APP_DATA if (intent.getBundleExtra(SearchManager.APP_DATA) != null) { Bundle bundle = new Bundle(); bundle.putAll(intent.getBundleExtra(SearchManager.APP_DATA)); searchIntent.putExtra(SearchManager.APP_DATA, bundle); } //-- SearchManager.QUERY String query = intent.getStringExtra(SearchManager.QUERY); if (query != null) { searchIntent.putExtra(SearchManager.QUERY, query); } //- android.speech.RecognizerIntent.EXTRA_RESULTS ArrayList<String> extraResults = intent .getStringArrayListExtra(android.speech.RecognizerIntent.EXTRA_RESULTS); if (extraResults != null) { searchIntent.putStringArrayListExtra(android.speech.RecognizerIntent.EXTRA_RESULTS, extraResults); } startActivityForResult(searchIntent, INTENT_REQUEST_SEARCH); return; } // Navigate to the requested path String navigateTo = intent.getStringExtra(EXTRA_NAVIGATE_TO); if (navigateTo != null && navigateTo.length() >= 0) { getCurrentNavigationFragment().changeCurrentDir(navigateTo); } }
From source file:com.ht.app.RestaurantsActivity.java
private void handleIntent(Intent intent) { if (intent == null || intent.getAction() == null) return;//from w ww . j a v a2 s .co m if (intent.getAction().equals(Intent.ACTION_SEARCH)) { doSearch(intent.getStringExtra(SearchManager.QUERY)); } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { getPlace(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY)); } }
From source file:gc.david.dfm.ui.MainActivity.java
/** * Handles all Intent types.//from w w w . j ava 2 s . c o m * * @param intent The input intent. */ private void handleIntents(final Intent intent) { Mint.leaveBreadcrumb("MainActivity::handleIntents"); if (intent != null) { if (intent.getAction().equals(Intent.ACTION_SEARCH)) { handleSearchIntent(intent); } else if (intent.getAction().equals(Intent.ACTION_VIEW)) { try { handleViewPositionIntent(intent); } catch (Exception e) { e.printStackTrace(); Mint.logException(e); } } } }
From source file:org.tlhInganHol.android.klingonassistant.BaseActivity.java
protected void displaySearchResults(String helpQuery) { Intent intent = new Intent(this, KlingonAssistant.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, helpQuery); startActivity(intent);//from w ww. j a v a 2 s . c o m overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); }
From source file:com.taw.gotothere.GoToThereActivity.java
/** * Handle any intents passed into the activity. Currently we only deal with * on, ACTION_SEARCH, which means we've been given a query string to search * for via the quick search box. We'll also handle the case where the activity * is restarted due to orientation changes; in this situation we still have the * intent with ACTION_SEARCH, so we check if we've already processed it; if so * don't bother geocoding./*w ww . j a v a2 s. c om*/ * * @param intent The intent to process * @param savedInstanceState The bundle passed into the activity on (re)start */ private void handleIntent(Intent intent, Bundle savedInstanceState) { if (intent.getAction().equals(Intent.ACTION_SEARCH)) { Log.d(TAG, "Started as a result of ACTION_SEARCH"); String query = intent.getStringExtra(SearchManager.QUERY); SharedPreferences prefs = getPreferences(Activity.MODE_PRIVATE); String previousQuery = prefs.getString(PREVIOUS_QUERY, null); if (previousQuery == null || !previousQuery.equals(query)) { Log.d(TAG, " Haven't processed this query before"); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, GoToThereSuggestionProvider.AUTHORITY, GoToThereSuggestionProvider.MODE); suggestions.saveRecentQuery(query, null); geocodeResult(query); } // Else UI stuff set up by onRestoreInstanceState() } }
From source file:de.vanita5.twittnuker.activity.support.HomeActivity.java
private int handleIntent(final Intent intent, final boolean firstCreate) { // use packge's class loader to prevent BadParcelException intent.setExtrasClassLoader(getClassLoader()); // reset intent setIntent(new Intent(this, HomeActivity.class)); final String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action)) { final String query = intent.getStringExtra(SearchManager.QUERY); final Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA); final long accountId; if (appSearchData != null && appSearchData.containsKey(EXTRA_ACCOUNT_ID)) { accountId = appSearchData.getLong(EXTRA_ACCOUNT_ID, -1); } else {/*from w w w. j a v a 2 s . c om*/ accountId = getDefaultAccountId(this); } openSearch(this, accountId, query); return -1; } final boolean refreshOnStart = mPreferences.getBoolean(KEY_REFRESH_ON_START, false); final long[] refreshedIds = intent.getLongArrayExtra(EXTRA_IDS); if (refreshedIds != null) { mTwitterWrapper.refreshAll(refreshedIds); } else if (firstCreate && refreshOnStart) { mTwitterWrapper.refreshAll(); } final int tab = intent.getIntExtra(EXTRA_INITIAL_TAB, -1); final int initialTab = tab != -1 ? tab : getAddedTabPosition(this, intent.getStringExtra(EXTRA_TAB_TYPE)); if (initialTab != -1 && mViewPager != null) { // clearNotification(initial_tab); } final Intent extraIntent = intent.getParcelableExtra(EXTRA_EXTRA_INTENT); if (extraIntent != null && firstCreate) { extraIntent.setExtrasClassLoader(getClassLoader()); SwipebackActivityUtils.startSwipebackActivity(this, extraIntent); } return initialTab; }
From source file:org.getlantern.firetweet.activity.support.HomeActivity.java
private int handleIntent(final Intent intent, final boolean firstCreate) { // use packge's class loader to prevent BadParcelException intent.setExtrasClassLoader(getClassLoader()); // reset intent setIntent(new Intent(this, HomeActivity.class)); final String action = intent.getAction(); if (Intent.ACTION_SEARCH.equals(action)) { final String query = intent.getStringExtra(SearchManager.QUERY); final Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA); final long accountId; if (appSearchData != null && appSearchData.containsKey(EXTRA_ACCOUNT_ID)) { accountId = appSearchData.getLong(EXTRA_ACCOUNT_ID, -1); } else {/*from w ww . j a v a2s . co m*/ accountId = getDefaultAccountId(this); } openSearch(this, accountId, query); return -1; } final boolean refreshOnStart = mPreferences.getBoolean(KEY_REFRESH_ON_START, false); final long[] refreshedIds = intent.getLongArrayExtra(EXTRA_REFRESH_IDS); if (refreshedIds != null) { mTwitterWrapper.refreshAll(refreshedIds); } else if (firstCreate && refreshOnStart) { mTwitterWrapper.refreshAll(); } final Uri uri = intent.getData(); final String tabType = uri != null ? Utils.matchTabType(uri) : null; int initialTab = -1; if (tabType != null) { final long accountId = ParseUtils.parseLong(uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID)); for (int i = mPagerAdapter.getCount() - 1; i > -1; i--) { final SupportTabSpec tab = mPagerAdapter.getTab(i); if (tabType.equals(tab.type)) { initialTab = i; if (hasAccountId(tab.args, accountId)) { break; } } } } if (initialTab != -1 && mViewPager != null) { // clearNotification(initial_tab); } final Intent extraIntent = intent.getParcelableExtra(EXTRA_EXTRA_INTENT); if (extraIntent != null && firstCreate) { extraIntent.setExtrasClassLoader(getClassLoader()); startActivity(extraIntent); } return initialTab; }
From source file:com.racoon.ampdroid.MainActivity.java
@SuppressLint("DefaultLocale") private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); ArrayList<Song> searchableSongs = new ArrayList<Song>(); Log.d("bugs", "active fragment " + String.valueOf(activeFragment)); /** find song **/ if (activeFragment < 2 || activeFragment == 6) { ArrayList<Song> result = new ArrayList<Song>(); if (activeFragment == 0) { searchableSongs = controller.getPlayNow(); } else if (activeFragment == 1) { searchableSongs = controller.getSongs(); } else if (activeFragment == 6) { searchableSongs = controller.getSelectedSongs(); }//from w w w . j a va 2 s. c o m for (int i = 0; i < searchableSongs.size(); i++) { if (searchableSongs.get(i).getTitle().toLowerCase().contains(query.toLowerCase())) { result.add(searchableSongs.get(i)); } } controller.setSelectedSongs(result); // Create new fragment and transaction SelectedSongsView newFragment = new SelectedSongsView(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.id.content_frame, newFragment); transaction.addToBackStack(null); activeFragment = 6; // Commit the transaction transaction.commit(); } /** find artist **/ else if (activeFragment == 2) { ArrayList<Artist> result = new ArrayList<Artist>(); for (int i = 0; i < controller.getArtists().size(); i++) { if (controller.getArtists().get(i).getName().toLowerCase().contains(query.toLowerCase())) { result.add(controller.getArtists().get(i)); } } controller.setSelectedArtists(result); // Create new fragment and transaction SelectedArtistsView newFragment = new SelectedArtistsView(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.id.content_frame, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); } /** find playlist **/ else if (activeFragment == 4) { ArrayList<Playlist> result = new ArrayList<Playlist>(); for (int i = 0; i < controller.getPlaylists().size(); i++) { if (controller.getPlaylists().get(i).getName().toLowerCase().contains(query.toLowerCase())) { result.add(controller.getPlaylists().get(i)); } } controller.setSelectedPlaylists(result); // Create new fragment and transaction SelectedPlaylistsView newFragment = new SelectedPlaylistsView(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.id.content_frame, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); } /** find album **/ else if (activeFragment == 3) { ArrayList<Album> result = new ArrayList<Album>(); for (int i = 0; i < controller.getAlbums().size(); i++) { if (controller.getAlbums().get(i).getName().toLowerCase().contains(query.toLowerCase())) { result.add(controller.getAlbums().get(i)); } } controller.setSelectedAlbums(result); // Create new fragment and transaction SelectedAlbumsView newFragment = new SelectedAlbumsView(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.id.content_frame, newFragment); transaction.addToBackStack(null); // Commit the transaction transaction.commit(); } Log.d("search", "searchquery " + query); } }
From source file:com.tct.mail.ui.OnePaneController.java
@Override protected void initializeActionBar() { final ActionBar actionBar = mActivity.getSupportActionBar(); if (actionBar == null) { return;//from w ww.j a v a 2 s . co m } 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 EmailActionBarController(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(); }