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.fastbootmobile.encore.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// ww w. j a va 2s. c om public void onClick(View view) { if (mActivePrint == null) { mActivePrint = new EchoPrint(RecognitionFragment.this); mActivePrint.startRecording(); onRecognitionStartUI(); // The buffer has a max size of 20 seconds, so we force stop at around 19 seconds mHandler.postDelayed(mStopRecognition, 19000); } 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:com.klinker.android.twitter.ui.drawer_activities.discover.trends.SearchedTrendsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down); try {/*from w w w. j av a 2s . c o m*/ ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } context = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); settings = AppSettings.getInstance(this); if (settings.advanceWindowed) { setUpWindow(); } Utils.setUpPopupTheme(context, settings); actionBar = getActionBar(); actionBar.setTitle(getResources().getString(R.string.search)); setContentView(R.layout.ptr_list_layout); mPullToRefreshLayout = (FullScreenSwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); mPullToRefreshLayout.setOnRefreshListener(new FullScreenSwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { onRefreshStarted(); } }); if (settings.addonTheme) { mPullToRefreshLayout.setColorScheme(settings.accentInt, SwipeProgressBar.COLOR2, settings.accentInt, SwipeProgressBar.COLOR3); } else { if (settings.theme != AppSettings.THEME_LIGHT) { mPullToRefreshLayout.setColorScheme(context.getResources().getColor(R.color.app_color), SwipeProgressBar.COLOR2, context.getResources().getColor(R.color.app_color), SwipeProgressBar.COLOR3); } else { mPullToRefreshLayout.setColorScheme(context.getResources().getColor(R.color.app_color), getResources().getColor(R.color.light_ptr_1), context.getResources().getColor(R.color.app_color), getResources().getColor(R.color.light_ptr_2)); } } listView = (AsyncListView) findViewById(R.id.listView); BitmapLruCache cache = App.getInstance(context).getBitmapCache(); ArrayListLoader loader = new ArrayListLoader(cache, context); ItemManager.Builder builder = new ItemManager.Builder(loader); builder.setPreloadItemsEnabled(true).setPreloadItemsCount(50); builder.setThreadPoolSize(4); listView.setItemManager(builder.build()); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { final int lastItem = firstVisibleItem + visibleItemCount; if (lastItem == totalItemCount && canRefresh) { getMore(); } } }); spinner = (LinearLayout) findViewById(R.id.list_progress); spinner.setVisibility(View.GONE); Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { } handleIntent(getIntent()); Utils.setActionBar(context); }
From source file:org.klnusbaum.udj.PlayerActivity.java
protected void onNewIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String searchQuery = intent.getStringExtra(SearchManager.QUERY); searchQuery = searchQuery.trim(); intent.putExtra(SearchManager.QUERY, searchQuery); intent.setClass(this, RegularSearchActivity.class); startActivityForResult(intent, 0); } else {/* ww w .j a v a 2s . c om*/ super.onNewIntent(intent); } }
From source file:org.addhen.smssync.presentation.view.ui.activity.MainActivity.java
private void handleSearchIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); query = query == null ? "" : query; mQuery = query;/*from w w w . ja v a 2 s . co m*/ performQuery(query); if (mSearchView != null) { mSearchView.setQuery(query, false); } } }
From source file:com.svpino.longhorn.activities.DashboardActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_VIEW.equals(intent.getAction())) { try {// w w w . j a v a 2 s. co m String symbol = intent.getData().getLastPathSegment(); addStockToWatchList(symbol); } catch (Throwable t) { Log.e(LOG_TAG, "Error while handling Intent.ACTION_VIEW.", t); } } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { performSearch(intent.getStringExtra(SearchManager.QUERY)); } }
From source file:com.inmovilizaciones.activity.ListarInmovilizacionesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); try {//from w w w.j a v a 2s . c om UtilidadesGenerales.context = this; setContentView(R.layout.listar_inmovilizacion_activity); this.app = (AplicacionInmovilizaciones) getApplication(); this.daoSession = this.app.getDaoSession(); this.inmovilizacionDao = this.daoSession.getInmovilizacionDao(); this.departamentosDao = this.daoSession.getDepartamentoDao(); this.municipioDao = this.daoSession.getMunicipioDao(); this.infraccionDao = this.daoSession.getInfraccionDao(); this.parqueaderoDao = this.daoSession.getParqueaderoDao(); this.zonasDao = this.daoSession.getZonasDao(); this.tipoIdentificacionDao = this.daoSession.getTipoIdentificacionDao(); this.gruasDao = this.daoSession.getGruaDao(); this.coloresDao = this.daoSession.getColorDao(); this.tipoServicioDao = this.daoSession.getTipoServicioDao(); this.claseVehiculoDao = this.daoSession.getClaseVehiculoDao(); this.personasDao = this.daoSession.getPersonaDao(); this.vehiculoDao = this.daoSession.getVehiculoDao(); this.rv = (RecyclerView) findViewById(R.id.rv); this.rv.setHasFixedSize(true); this.llm = new LinearLayoutManager(this); this.rv.setLayoutManager(this.llm); Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults") && !intent.hasExtra("query")) { onSearchRequested(); } btnAgregarComparendo = (FloatingActionButton) findViewById(R.id.agregarComparendo); btnAgregarComparendo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (ListarInmovilizacionesActivity.this.validarParametrizacion().equals("")) { ListarInmovilizacionesActivity.this .startActivityForResult(new Intent(ListarInmovilizacionesActivity.this, AgregarInmovilizacionActivity.class), NOTIFICACIONES_ID); } } }); } catch (Exception ex) { ex.printStackTrace(); } }
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);/*w w w . j a v a 2 s . c o m*/ // 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:org.huxizhijian.hhcomicviewer.ui.main.MainActivity.java
private void initView() { //?actionbar/*from ww w . j a v a 2 s . 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 w w w. jav a 2 s . 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:com.teocci.utubinbg.MainActivity.java
/** * Options menu in action bar// w w w .j a v a2s . c om * * @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; }