List of usage examples for android.app SearchManager QUERY
String QUERY
To view the source code for android.app SearchManager QUERY.
Click Source Link
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 w w .j a v a 2 s . c o m * * @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:gc.david.dfm.ui.MainActivity.java
/** * Handles a search intent./*from w w w .j a v a 2s. c o m*/ * * @param intent Input intent. */ private void handleSearchIntent(final Intent intent) { Mint.leaveBreadcrumb("MainActivity::handleSearchIntent"); // Para controlar instancias nicas, no queremos que cada vez que // busquemos nos inicie una nueva instancia de la aplicacin final String query = intent.getStringExtra(SearchManager.QUERY); if (currentLocation != null) { new SearchPositionByName().execute(query); } if (searchMenuItem != null) { MenuItemCompat.collapseActionView(searchMenuItem); } }
From source file:net.reichholf.dreamdroid.activities.MainActivity.java
@Override public boolean onQueryTextSubmit(String query) { Bundle args = new Bundle(); args.putString(SearchManager.QUERY, query); Fragment f = new EpgSearchFragment(); f.setArguments(args);//from ww w . j a va 2s. c o m showDetails(f, true); return true; }
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);//w w w .ja va 2 s . c om overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); }
From source file:org.runbuddy.tomahawk.activities.TomahawkMainActivity.java
private void handleIntent(Intent intent) { if (MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH.equals(intent.getAction())) { intent.setAction(null);/*from w ww. j av a2s . c om*/ String playbackManagerId = getSupportMediaController().getExtras() .getString(PlaybackService.EXTRAS_KEY_PLAYBACKMANAGER); PlaybackManager playbackManager = PlaybackManager.getByKey(playbackManagerId); MediaPlayIntentHandler intentHandler = new MediaPlayIntentHandler( getSupportMediaController().getTransportControls(), playbackManager); intentHandler.mediaPlayFromSearch(intent.getExtras()); } if ("com.google.android.gms.actions.SEARCH_ACTION".equals(intent.getAction())) { intent.setAction(null); String query = intent.getStringExtra(SearchManager.QUERY); if (query != null && !query.isEmpty()) { DatabaseHelper.get().addEntryToSearchHistory(query); Bundle bundle = new Bundle(); bundle.putString(TomahawkFragment.QUERY_STRING, query); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC); FragmentUtils.replace(TomahawkMainActivity.this, SearchPagerFragment.class, bundle); } } if (SHOW_PLAYBACKFRAGMENT_ON_STARTUP.equals(intent.getAction())) { intent.setAction(null); // if this Activity is being shown after the user clicked the notification if (mSlidingUpPanelLayout != null) { mSlidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); } } if (intent.hasExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE)) { intent.removeExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); Bundle bundle = new Bundle(); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC_SMALL); FragmentUtils.replace(this, PreferencePagerFragment.class, bundle); } if (intent.getData() != null) { final Uri data = intent.getData(); intent.setData(null); List<String> pathSegments = data.getPathSegments(); String host = data.getHost(); String scheme = data.getScheme(); if ((scheme != null && (scheme.equals("spotify") || scheme.equals("tomahawk"))) || (host != null && (host.contains("spotify.com") || host.contains("hatchet.is") || host.contains("toma.hk") || host.contains("beatsmusic.com") || host.contains("deezer.com") || host.contains("rdio.com") || host.contains("soundcloud.com")))) { PipeLine.get().lookupUrl(data.toString()); } else if ((pathSegments != null && pathSegments.get(pathSegments.size() - 1).endsWith(".xspf")) || (intent.getType() != null && intent.getType().equals("application/xspf+xml"))) { TomahawkRunnable r = new TomahawkRunnable(TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_HIGH) { @Override public void run() { Playlist pl = XspfParser.parse(data); if (pl != null) { final Bundle bundle = new Bundle(); bundle.putString(TomahawkFragment.PLAYLIST, pl.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } }); } } }; ThreadManager.get().execute(r); } else if (pathSegments != null && (pathSegments.get(pathSegments.size() - 1).endsWith(".axe") || pathSegments.get(pathSegments.size() - 1).endsWith(".AXE"))) { InstallPluginConfigDialog dialog = new InstallPluginConfigDialog(); Bundle args = new Bundle(); args.putString(InstallPluginConfigDialog.PATH_TO_AXE_URI_STRING, data.toString()); dialog.setArguments(args); dialog.show(getSupportFragmentManager(), null); } else { String albumName; String trackName; String artistName; try { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(this, data); albumName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM); artistName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); trackName = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); retriever.release(); } catch (Exception e) { Log.e(TAG, "handleIntent: " + e.getClass() + ": " + e.getLocalizedMessage()); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { String msg = TomahawkApp.getContext().getString(R.string.invalid_file); Toast.makeText(TomahawkApp.getContext(), msg, Toast.LENGTH_LONG).show(); } }); return; } if (TextUtils.isEmpty(trackName) && pathSegments != null) { trackName = pathSegments.get(pathSegments.size() - 1); } Query query = Query.get(trackName, albumName, artistName, false); Result result = Result.get(data.toString(), query.getBasicTrack(), UserCollectionStubResolver.get()); float trackScore = query.howSimilar(result); query.addTrackResult(result, trackScore); Bundle bundle = new Bundle(); List<Query> queries = new ArrayList<>(); queries.add(query); Playlist playlist = Playlist.fromQueryList(IdGenerator.getSessionUniqueStringId(), "", "", queries); playlist.setFilled(true); playlist.setName(artistName + " - " + trackName); bundle.putString(TomahawkFragment.PLAYLIST, playlist.getCacheKey()); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_DYNAMIC); FragmentUtils.replace(TomahawkMainActivity.this, PlaylistEntriesFragment.class, bundle); } } }
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 ava2 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. 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_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 w w . ja va2 s. c o 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:org.andstatus.app.msg.TimelineActivity.java
private void parseAppSearchData(Intent intentNew) { Bundle appSearchData = intentNew.getBundleExtra(SearchManager.APP_DATA); if (appSearchData == null || !mListParametersNew .parseUri(Uri.parse(appSearchData.getString(IntentExtra.TIMELINE_URI.key, "")))) { return;/*from ww w.j a va2 s . c o m*/ } /* The query itself is still from the Intent */ mListParametersNew.mSearchQuery = TimelineListParameters .notNullString(intentNew.getStringExtra(SearchManager.QUERY)); if (!TextUtils.isEmpty(mListParametersNew.mSearchQuery) && appSearchData.getBoolean(IntentExtra.GLOBAL_SEARCH.key, false)) { setSyncing("Global search: " + mListParametersNew.mSearchQuery, true); MyServiceManager .sendManualForegroundCommand( CommandData .searchCommand( isTimelineCombined() ? "" : MyContextHolder.get().persistentAccounts() .getCurrentAccountName(), mListParametersNew.mSearchQuery)); } }
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 ww w . j a v a2 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); } }