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.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/* w w w.j ava2 s. c o m*/ 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:net.sourceforge.servestream.activity.MainActivity.java
@Override public void startActivity(Intent intent) { // check if search intent if (Intent.ACTION_SEARCH.equals(intent.getAction())) { Fragment fragment = getSupportFragmentManager().findFragmentByTag(mTag); if (fragment != null && fragment instanceof BrowseFragment) { intent.putParcelableArrayListExtra("uris", ((BrowseFragment) fragment).getUris()); }//from w w w . ja va 2 s. c om } super.startActivity(intent); }
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); }//w w w. j a v a 2 s .c om }
From source file:com.online.fullsail.SaveWebMedia.java
@Override protected void onPostExecute(File download) { String fileString = download.toString(); mNM.cancel(timestamp);/*from www . j ava 2s .c om*/ System.gc(); String fileName = fileString.substring(fileString.lastIndexOf('/') + 1, fileString.length()); String fileExt = fileName.substring(fileName.lastIndexOf('.') + 1, fileName.length()); File downFile = new File(externalData, fileName); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(downFile), "application/" + fileExt); List<ResolveInfo> intents = this.context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (intents == null || intents.size() == 0) { intent.setDataAndType(Uri.fromFile(downFile), "video/" + fileExt); intents = this.context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (intents == null || intents.size() == 0) { intent.setDataAndType(Uri.fromFile(downFile), "image/" + fileExt); intents = this.context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (intents == null || intents.size() == 0) { intent = new Intent(Intent.ACTION_SEARCH); if (Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.ECLAIR) { intent.setPackage("com.android.vending"); } intent.putExtra("query", fileExt); } } } intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this.context, 0, intent, PendingIntent.FLAG_ONE_SHOT); Notification notification = null; Resources resources = this.context.getResources(); String[] mediaTypes = resources.getStringArray(R.array.media); boolean acceptedType = false; for (int i = 0; i < mediaTypes.length; i++) { if (fileExt.toLowerCase().equals(mediaTypes[i])) { acceptedType = true; } } if (acceptedType) { Bitmap preview = null; String[] videoTypes = resources.getStringArray(R.array.movFiles); for (int i = 0; i < videoTypes.length; i++) { if (fileExt.toLowerCase().equals(videoTypes[i])) { preview = getVideoFrame(fileString); } } String[] imageTypes = resources.getStringArray(R.array.movFiles); for (int i = 0; i < imageTypes.length; i++) { if (fileExt.toLowerCase().equals(imageTypes[i])) { preview = decodeBitmapFile(fileString); } } NotificationCompat.Builder builder = new NotificationCompat.Builder(this.context); builder.setTicker(this.context.getString(R.string.notify_download_complete)) .setWhen(System.currentTimeMillis()) .setContentTitle(this.context.getString(R.string.Document_complete)) .setContentText(this.context.getString(R.string.Pdf_completed, fileName)) .setSmallIcon(R.drawable.icon).setAutoCancel(true).setPriority(Notification.PRIORITY_HIGH) .setContentIntent(contentIntent); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { notification = new NotificationCompat.BigPictureStyle(builder).bigPicture(preview).build(); } else { notification = builder.build(); } } else { NotificationCompat.Builder builder = new NotificationCompat.Builder(this.context); builder.setContentTitle(this.context.getString(R.string.Document_complete)) .setContentText(this.context.getString(R.string.Pdf_completed, fileName)) .setSmallIcon(R.drawable.icon).setAutoCancel(true).setPriority(Notification.PRIORITY_HIGH) .setContentIntent(contentIntent); notification = builder.build(); } notification.flags |= Notification.FLAG_AUTO_CANCEL; mNM.notify(timestamp, notification); }
From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent);//from w w w . j av a2s . c o m final MBApplicationController appController = MBApplicationController.getInstance(); if (Intent.ACTION_SEARCH.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())) { appController.handleSearchRequest(intent); } final String outcomeName = intent.getStringExtra(Constants.C_INTENT_POST_INITIALOUTCOMES_OUTCOMENAME); if (StringUtil.isNotBlank(outcomeName)) { runOnUiThread(new Runnable() { @Override public void run() { if (appController.getOutcomeHandler() == null) { appController.startOutcomeHandler(); } appController.handleOutcome(new MBOutcome(outcomeName, null)); } }); } }
From source file:it.iziozi.iziozi.gui.IORemoteImageSearchActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); searchImages(query);/*from w w w . j ava2s. c om*/ } }
From source file:fr.seeks.SuggestionProvider.java
public void setCursorOfQueryThrow(Uri uri, String query, MatrixCursor matrix) throws MalformedURLException, IOException { String url = getUrlFromKeywords(query); Log.v(TAG, "Query:" + url); String json = null;//from www. j av a2s .c o m while (json == null) { HttpURLConnection connection = null; connection = (HttpURLConnection) (new URL(url)).openConnection(); try { connection.setDoOutput(true); connection.setChunkedStreamingMode(0); connection.setInstanceFollowRedirects(true); connection.connect(); int response = connection.getResponseCode(); if (response == HttpURLConnection.HTTP_MOVED_PERM || response == HttpURLConnection.HTTP_MOVED_TEMP) { Map<String, List<String>> list = connection.getHeaderFields(); for (Entry<String, List<String>> entry : list.entrySet()) { String value = ""; for (String s : entry.getValue()) { value = value + ";" + s; } Log.v(TAG, entry.getKey() + ":" + value); } // FIXME url = ""; return; } InputStream in = connection.getInputStream(); BufferedReader r = new BufferedReader(new InputStreamReader(in)); StringBuilder builder = new StringBuilder(); String line; while ((line = r.readLine()) != null) { builder.append(line); } json = builder.toString(); /* * Log.v(TAG, "** JSON START **"); Log.v(TAG, json); Log.v(TAG, * "** JSON END **"); */ } catch (IOException e) { e.printStackTrace(); return; } finally { connection.disconnect(); } } JSONArray snippets; JSONObject object; JSONArray suggestions; Boolean show_snippets = mPrefs.getBoolean("show_snippets", false); if (show_snippets) { try { object = (JSONObject) new JSONTokener(json).nextValue(); snippets = object.getJSONArray("snippets"); } catch (JSONException e) { e.printStackTrace(); return; } Log.v(TAG, "Snippets found: " + snippets.length()); for (int i = 0; i < snippets.length(); i++) { JSONObject snip; try { snip = snippets.getJSONObject(i); matrix.newRow().add(i).add(snip.getString("title")).add(snip.getString("summary")) .add(snip.getString("title")).add(Intent.ACTION_SEND).add(snip.getString("url")); } catch (JSONException e) { e.printStackTrace(); continue; } } } else { try { object = (JSONObject) new JSONTokener(json).nextValue(); suggestions = object.getJSONArray("suggestions"); } catch (JSONException e) { e.printStackTrace(); return; } Log.v(TAG, "Suggestions found: " + suggestions.length()); for (int i = 0; i < suggestions.length(); i++) { try { matrix.newRow().add(i).add(suggestions.getString(i)).add("").add(suggestions.getString(i)) .add(Intent.ACTION_SEARCH).add(""); } catch (JSONException e) { e.printStackTrace(); continue; } } } getContext().getContentResolver().notifyChange(uri, null); }
From source file:com.benlinskey.greekreference.MainActivity.java
/** * Processes an <code>Intent</code> if it can be handled by this {@code Activity} or * throws an exception if this {@code Activity} cannot handle the specified {@code Intent}. * @param intent the {@code Intent} to handle *//*from w ww. ja v a 2 s .co m*/ void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra((SearchManager.QUERY)); search(query); } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri data = intent.getData(); getLexiconEntry(data); } else if (ACTION_SET_MODE.equals(intent.getAction())) { String modeName = intent.getStringExtra(KEY_MODE); Mode mode = Mode.getModeFromName(modeName); switchToMode(mode); } }
From source file:edu.cmu.cylab.starslinger.view.PickRecipientsActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String searchQuery = intent.getStringExtra(SearchManager.QUERY); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, CustomSuggestionsProvider.AUTHORITY, CustomSuggestionsProvider.MODE); suggestions.saveRecentQuery(searchQuery, null); searchContacts(searchQuery);/*ww w . jav a 2 s .c o m*/ } }
From source file:org.braiden.fpm2.PasswordItemListActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // if this acitity receives input from search widget, apply the search string a listView text filter if (intent.getAction().equals(Intent.ACTION_SEARCH) && getFpmApplication().isCryptOpen()) { String searchString = intent.getStringExtra(SearchManager.QUERY); getListView().setFilterText(searchString); }/*from w w w. jav a2 s .c o m*/ }