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.example.android.navigationdrawerexample.SecondActivity.java
@Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.overflow_search: // create intent to perform web search for this planet Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle()); // catch event that there's no activity to handle intent if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent);/* w ww.j a va 2s . c o m*/ } else { Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); } break; default: break; } return false; }
From source file:org.tlhInganHol.android.klingonassistant.FloatingWindow.java
private void launchEntry(String entryId) { if (entryId == null) { return;// w ww . j a v a 2s.c o m } Intent entryIntent = new Intent(this, EntryActivity.class); // Form the URI for the entry. Uri uri = Uri.parse(KlingonContentProvider.CONTENT_URI + "/get_entry_by_id/" + entryId); entryIntent.setData(uri); // Save the query that this entry is a part of. entryIntent.putExtra(SearchManager.QUERY, mEditText.getText().toString()); // This needs to be set since this is called outside of an activity. entryIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(entryIntent); }
From source file:org.huxizhijian.hhcomicviewer.ui.main.MainActivity.java
private void initView() { //?actionbar//from w ww . jav a 2s. c o m setSupportActionBar(mBinding.toolbar); CommonUtils.setStatusBarTint(this, getResources().getColor(R.color.colorPrimaryDark)); //searchView mBinding.searchView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String suggestion = mBinding.searchView.getSuggestionAtPosition(position); mBinding.searchView.setQuery(suggestion, true); } }); mBinding.searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { if (TextUtils.isEmpty(query)) { Toast.makeText(MainActivity.this, R.string.search_query_will_no_be_empty, Toast.LENGTH_SHORT) .show(); return true; } Intent intent = new Intent(MainActivity.this, SearchActivity.class); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, query); startActivity(intent); return true; } @Override public boolean onQueryTextChange(String newText) { return false; } }); //?search view?? mBinding.searchView.setSearchViewListener(new MaterialSearchView.SearchViewListener() { @Override public void onSearchViewOpened() { //?? showHistory(); } @Override public void onSearchViewClosed() { if (mHistoryPop != null) { mHistoryPop.dismiss(); } } }); }
From source file:com.fastbootmobile.encore.app.fragments.ListenNowFragment.java
private void setupHeader(ParallaxScrollListView listView) { LayoutInflater inflater = LayoutInflater.from(listView.getContext()); mHeaderView = inflater.inflate(R.layout.header_listen_now, listView, false); mCardSearchBox = (CardView) mHeaderView.findViewById(R.id.cardSearchBox); mSearchBox = (EditText) mHeaderView.findViewById(R.id.ebSearch); mSearchBox.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/*from www. ja v a 2s . c o m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { final String query = v.getText().toString(); Intent intent = new Intent(getActivity(), SearchActivity.class); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, query); v.getContext().startActivity(intent); // Clear the box once searched v.setText(null); return true; } }); listView.addParallaxedHeaderView(mHeaderView); }
From source file:ca.rmen.android.poetassistant.main.MainActivity.java
@Override protected void onNewIntent(Intent intent) { Log.d(TAG, "onNewIntent() called with: " + "intent = [" + intent + "]"); setIntent(intent);/*from www . ja va 2s. c om*/ // The user entered a search term either by typing or by voice if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getDataString(); if (TextUtils.isEmpty(query)) { query = intent.getStringExtra(SearchManager.QUERY); } if (TextUtils.isEmpty(query)) { CharSequence userQuery = intent.getCharSequenceExtra(SearchManager.USER_QUERY); if (!TextUtils.isEmpty(userQuery)) query = userQuery.toString(); } if (TextUtils.isEmpty(query)) return; mSearch.addSuggestions(query); mSearch.search(query); } // We got here from a deep link else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri data = getIntent().getData(); handleDeepLink(data); } // Play some text in the tts tab else if (Intent.ACTION_SEND.equals(intent.getAction())) { mBinding.viewPager.setCurrentItem(mPagerAdapter.getPositionForTab(Tab.READER)); String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); ReaderFragment readerFragment = (ReaderFragment) mPagerAdapter.getFragment(mBinding.viewPager, Tab.READER); readerFragment.setText(sharedText); } }
From source file:com.teocci.utubinbg.MainActivity.java
/** * Options menu in action bar/*from ww w . j a va2 s. co m*/ * * @param menu * @return */ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); } //suggestions final CursorAdapter suggestionAdapter = new SimpleCursorAdapter(this, R.layout.dropdown_menu, null, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1 }, new int[] { android.R.id.text1 }, 0); final List<String> suggestions = new ArrayList<>(); searchView.setSuggestionsAdapter(suggestionAdapter); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { searchView.setQuery(suggestions.get(position), false); searchView.clearFocus(); Intent suggestionIntent = new Intent(Intent.ACTION_SEARCH); suggestionIntent.putExtra(SearchManager.QUERY, suggestions.get(position)); handleIntent(suggestionIntent); return true; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { return false; //if true, no new intent is started } @Override public boolean onQueryTextChange(String suggestion) { // check network connection. If not available, do not query. // this also disables onSuggestionClick triggering if (suggestion.length() > 2) { //make suggestions after 3rd letter if (networkConf.isNetworkAvailable()) { new JsonAsyncTask(new JsonAsyncTask.AsyncResponse() { @Override public void processFinish(ArrayList<String> result) { suggestions.clear(); suggestions.addAll(result); String[] columns = { BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1 }; MatrixCursor cursor = new MatrixCursor(columns); for (int i = 0; i < result.size(); i++) { String[] tmp = { Integer.toString(i), result.get(i) }; cursor.addRow(tmp); } suggestionAdapter.swapCursor(cursor); } }).execute(suggestion); return true; } } return false; } }); return true; }
From source file:com.oceansky.yellow.app.fragments.RecognitionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment RelativeLayout root = (RelativeLayout) inflater.inflate(R.layout.fragment_recognition, container, false); // Recognition layout mButtonLayout = (LinearLayout) root.findViewById(R.id.llRecognitionButton); mRecognitionButton = (AnimatedMicButton) root.findViewById(R.id.btnStartRec); mTvStatus = (TextView) root.findViewById(R.id.tvStatus); mTvDetails = (TextView) root.findViewById(R.id.tvDetailsText); // Result layout mCardResult = (CardView) root.findViewById(R.id.cardResult); mTvAlbum = (TextView) root.findViewById(R.id.tvAlbumName); mTvArtist = (TextView) root.findViewById(R.id.tvArtistName); mTvTitle = (TextView) root.findViewById(R.id.tvTrackName); mIvArt = (ImageView) root.findViewById(R.id.ivRecognitionArt); mSearchButton = (Button) root.findViewById(R.id.btnSearch); mTvOfflineError = (TextView) root.findViewById(R.id.tvErrorMessage); mTvOfflineError.setText(R.string.error_recognition_unavailable_offline); ProviderAggregator aggregator = ProviderAggregator.getDefault(); mTvOfflineError.setVisibility(aggregator.isOfflineMode() ? View.VISIBLE : View.GONE); mRecognitionButton.setOnClickListener(new View.OnClickListener() { @Override/*from ww w . j a v a 2 s.com*/ public void onClick(View view) { if (mActivePrint == null) { // Ensure we have the permissions to record audio if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.RECORD_AUDIO }, MY_PERMISSIONS_REQUEST_RECORD_AUDIO); } else { startRecording(); } } else { mHandler.removeCallbacks(mStopRecognition); mStopRecognition.run(); } } }); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent search = new Intent(getActivity(), SearchActivity.class); search.setAction(Intent.ACTION_SEARCH); search.putExtra(SearchManager.QUERY, mLastResult.ArtistName + " " + mLastResult.TrackName); startActivity(search); } }); return root; }
From source file:nuclei.media.MediaInterface.java
void onConnected() { try {//www . ja va2 s . c o m Context context = mFragmentActivity == null ? mLActivity : mFragmentActivity; if (context == null) return; mMediaControls = new MediaControllerCompat(context, mMediaBrowser.getSessionToken()); mMediaCallback = new MediaControllerCompat.Callback() { @Override public void onPlaybackStateChanged(PlaybackStateCompat state) { MediaInterface.this.onPlaybackStateChanged(state); } @Override public void onSessionEvent(String event, Bundle extras) { MediaInterface.this.onSessionEvent(event, extras); } @Override public void onMetadataChanged(MediaMetadataCompat metadata) { MediaInterface.this.onMetadataChanged(metadata); } }; mMediaControls.registerCallback(mMediaCallback); if (mFragmentActivity != null) { MediaControllerCompat.setMediaController(mFragmentActivity, mMediaControls); //mFragmentActivity.setSupportMediaController(mMediaControls); } else if (mLActivity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) setMediaControllerL(); if (mPlayerControls != null) mPlayerControls.setMediaControls(mCallbacks, mMediaControls); if (mMediaControls.getPlaybackState() != null) onPlaybackStateChanged(mMediaControls.getPlaybackState()); final Intent intent = mFragmentActivity == null ? mLActivity.getIntent() : mFragmentActivity.getIntent(); if (MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH.equals(intent.getAction())) { final Bundle params = intent.getExtras(); final String query = params.getString(SearchManager.QUERY); LOG.i("Starting from voice search query=" + query); mMediaControls.getTransportControls().playFromSearch(query, params); } if (mCallbacks != null) { mCallbacks.onConnected(this); MediaMetadataCompat metadataCompat = mMediaControls.getMetadata(); if (metadataCompat != null) { final long duration = metadataCompat.getLong(MediaMetadataCompat.METADATA_KEY_DURATION); if (duration > 0) mCallbacks.setTimeTotal(this, duration); } } Bundle extras = mMediaControls.getExtras(); if (extras != null && extras.containsKey(MediaService.EXTRA_CONNECTED_CAST)) { mCallbacks.onCasting(this, extras.getString(MediaService.EXTRA_CONNECTED_CAST)); } if (mPlayerControls != null && mPlayerControls.isPlaying()) mHandler.start(); if (mSurface != null) setSurface(mSurface); LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ACTION_CONNECTED)); } catch (RemoteException err) { LOG.e("Error in onConnected", err); } }
From source file:com.tavant.droid.womensecurity.fragments.ContactsListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check if this fragment is part of a two-pane set up or a single pane // by reading a // boolean from the application resource directories. This lets allows // us to easily specify // which screen sizes should use a two-pane layout by setting this // boolean in the // corresponding resource size-qualified directory. // mIsTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes); // Let this fragment contribute menu items setHasOptionsMenu(true);//from w ww . j a va2s . c o m // Create the main contacts adapter mAdapter = new ContactsAdapter(getActivity()); if (savedInstanceState != null) { // If we're restoring state after this fragment was recreated then // retrieve previous search term and previously selected search // result. mSearchTerm = savedInstanceState.getString(SearchManager.QUERY); mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0); } /* * An ImageLoader object loads and resizes an image in the background * and binds it to the QuickContactBadge in each item layout of the * ListView. ImageLoader implements memory caching for each image, which * substantially improves refreshes of the ListView as the user scrolls * through it. * * To learn more about downloading images asynchronously and caching the * results, read the Android training class Displaying Bitmaps * Efficiently. * * http://developer.android.com/training/displaying-bitmaps/ */ mImageLoader = new ImageLoader(getActivity(), getListPreferredItemHeight()) { @Override protected Bitmap processBitmap(Object data) { // This gets called in a background thread and passed the data // from // ImageLoader.loadImage(). return loadContactPhotoThumbnail((String) data, getImageSize()); } }; // Set a placeholder loading image for the image loader mImageLoader.setLoadingImage(R.drawable.ic_contact_picture_holo_light); // Add a cache to the image loader mImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f); }
From source file:com.msted.lensrocket.activities.FriendsListActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); LensRocketLogger.i(TAG, "Search for: " + query); }//from ww w. j a v a2 s . com }