List of usage examples for android.content Intent EXTRA_STREAM
String EXTRA_STREAM
To view the source code for android.content Intent EXTRA_STREAM.
Click Source Link
From source file:ch.blinkenlights.android.vanilla.MediaUtils.java
/** * Creates and sends a share intent across the system. * @param ctx context to execute resolving on. * @param song the song to share./*from w w w. j a va 2 s . c o m*/ */ public static void shareMedia(Context ctx, Song song) { if (song == null || song.path == null) return; Uri uri = null; try { uri = FileProvider.getUriForFile(ctx, ctx.getApplicationContext().getPackageName() + ".fileprovider", new File(song.path)); } catch (IllegalArgumentException e) { Toast.makeText(ctx, R.string.share_failed, Toast.LENGTH_SHORT).show(); } if (uri == null) return; // Fileprovider failed, we can not continue. Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("audio/*"); intent.putExtra(Intent.EXTRA_STREAM, uri); try { ctx.startActivity(Intent.createChooser(intent, ctx.getString(R.string.sendto))); } catch (ActivityNotFoundException e) { Toast.makeText(ctx, R.string.no_receiving_apps, Toast.LENGTH_SHORT).show(); } }
From source file:im.vector.activity.ImageWebViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_web_view); mWebView = (WebView) findViewById(R.id.image_webview); final Intent intent = getIntent(); if (intent == null) { Log.e(LOG_TAG, "Need an intent to view."); finish();//from w w w . ja v a 2 s .c o m return; } mHighResUri = intent.getStringExtra(KEY_HIGHRES_IMAGE_URI); final int rotationAngle = mRotationAngle = intent.getIntExtra(KEY_IMAGE_ROTATION, 0); mOrientation = intent.getIntExtra(KEY_IMAGE_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); mHighResMimeType = intent.getStringExtra(KEY_HIGHRES_MIME_TYPE); if (mHighResUri == null) { Log.e(LOG_TAG, "No Image URI"); finish(); return; } final int thumbnailWidth = intent.getIntExtra(KEY_THUMBNAIL_WIDTH, 0); final int thumbnailHeight = intent.getIntExtra(KEY_THUMBNAIL_HEIGHT, 0); if ((thumbnailWidth <= 0) || (thumbnailHeight <= 0)) { Log.e(LOG_TAG, "Invalid thumbnail size"); finish(); return; } final MXMediasCache mediasCache = Matrix.getInstance(this).getMediasCache(); File mediaFile = mediasCache.mediaCacheFile(mHighResUri, mHighResMimeType); // is the high picture already downloaded ? if (null != mediaFile) { mThumbnailUri = mHighResUri = "file://" + mediaFile.getPath(); } String css = computeCss(mThumbnailUri, thumbnailWidth, thumbnailHeight, rotationAngle); final String viewportContent = "width=640"; final PieFractionView pieFractionView = (PieFractionView) findViewById(R.id.download_zoomed_image_piechart); // is the high picture already downloaded ? if (null != mediaFile) { pieFractionView.setVisibility(View.GONE); } else { mThumbnailUri = null; // try to retrieve the thumbnail mediaFile = mediasCache.mediaCacheFile(mHighResUri, thumbnailWidth, thumbnailHeight, null); if (null == mediaFile) { Log.e(LOG_TAG, "No Image thumbnail"); finish(); return; } final String loadingUri = mHighResUri; mThumbnailUri = mHighResUri = "file://" + mediaFile.getPath(); final String downloadId = mediasCache.loadBitmap(this, loadingUri, mRotationAngle, mOrientation, mHighResMimeType); if (null != downloadId) { pieFractionView.setFraction(mediasCache.progressValueForDownloadId(downloadId)); mediasCache.addDownloadListener(downloadId, new MXMediasCache.DownloadCallback() { @Override public void onDownloadProgress(String aDownloadId, int percentageProgress) { if (aDownloadId.equals(downloadId)) { pieFractionView.setFraction(percentageProgress); } } @Override public void onDownloadComplete(String aDownloadId) { if (aDownloadId.equals(downloadId)) { pieFractionView.setVisibility(View.GONE); final File mediaFile = mediasCache.mediaCacheFile(loadingUri, mHighResMimeType); if (null != mediaFile) { Uri uri = Uri.fromFile(mediaFile); mHighResUri = uri.toString(); runOnUiThread(new Runnable() { @Override public void run() { Uri mediaUri = Uri.parse(mHighResUri); // save in the gallery CommonActivityUtils.saveImageIntoGallery(ImageWebViewActivity.this, mediaFile); // refresh the UI loadImage(mediaUri, viewportContent, computeCss(mHighResUri, thumbnailWidth, thumbnailHeight, rotationAngle)); } }); } } } }); } } mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setLoadWithOverviewMode(true); mWebView.getSettings().setUseWideViewPort(true); mWebView.getSettings().setBuiltInZoomControls(true); loadImage(Uri.parse(mHighResUri), viewportContent, css); mWebView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { final String highResMediaURI = intent.getStringExtra(KEY_HIGHRES_IMAGE_URI); final MXMediasCache mediasCache = Matrix.getInstance(ImageWebViewActivity.this).getMediasCache(); final File mediaFile = mediasCache.mediaCacheFile(highResMediaURI, mHighResMimeType); if (null != mediaFile) { FragmentManager fm = ImageWebViewActivity.this.getSupportFragmentManager(); IconAndTextDialogFragment fragment = (IconAndTextDialogFragment) fm .findFragmentByTag(TAG_FRAGMENT_IMAGE_OPTIONS); if (fragment != null) { fragment.dismissAllowingStateLoss(); } final Integer[] icons = { R.drawable.ic_material_share, R.drawable.ic_material_forward }; final Integer[] textIds = { R.string.share, R.string.forward }; fragment = IconAndTextDialogFragment.newInstance(icons, textIds, Color.WHITE, ImageWebViewActivity.this.getResources().getColor(R.color.vector_title_color)); fragment.setOnClickListener(new IconAndTextDialogFragment.OnItemClickListener() { @Override public void onItemClick(IconAndTextDialogFragment dialogFragment, int position) { final Integer selectedVal = textIds[position]; ImageWebViewActivity.this.runOnUiThread(new Runnable() { @Override public void run() { Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(mHighResMimeType); try { sendIntent.putExtra(Intent.EXTRA_STREAM, ConsoleContentProvider.absolutePathToUri(ImageWebViewActivity.this, mediaFile.getAbsolutePath())); } catch (Exception e) { } if (selectedVal == R.string.forward) { CommonActivityUtils.sendFilesTo(ImageWebViewActivity.this, sendIntent); } else { startActivity(sendIntent); } } }); } }); fragment.show(fm, TAG_FRAGMENT_IMAGE_OPTIONS); return true; } return false; } }); }
From source file:com.hijacker.SendLogActivity.java
public void onUseEmail(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "kiriakopoulos44@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Hijacker bug report"); Uri attachment = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider", report); intent.putExtra(Intent.EXTRA_STREAM, attachment); intent.putExtra(Intent.EXTRA_TEXT, extraView.getText().toString()); startActivity(intent);//from w w w. j av a 2 s.co m }
From source file:com.android.talkback.labeling.LabelManagerSummaryActivity.java
private void addExportCustomLabelClickListener() { final Button exportLabel = (Button) findViewById(R.id.export_labels); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { exportLabel.setVisibility(View.GONE); return;/*from w w w .ja v a 2s . c o m*/ } exportLabel.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { CustomLabelMigrationManager exporter = new CustomLabelMigrationManager(getApplicationContext()); exporter.exportLabels(new CustomLabelMigrationManager.SimpleLabelMigrationCallback() { @Override public void onLabelsExported(File file) { if (file == null) { notifyLabelExportFailure(); return; } Uri uri = FileProvider.getUriForFile(getApplicationContext(), FILE_AUTHORITY, file); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.setType("application/json"); String activityTitle = getResources().getString(R.string.label_choose_app_to_export); startActivity(Intent.createChooser(shareIntent, activityTitle)); } @Override public void onFail() { notifyLabelExportFailure(); } }); return; } }); }
From source file:com.cw.litenote.operation.mail.MailPagesFragment.java
void sendEMail(String strEMailAddr, // eMail address String[] attachmentFileName, // attachment name String[] picFileNameArray) // attachment picture file name { mAttachmentFileName = attachmentFileName; // new ACTION_SEND intent mEMailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); // for multiple attachments // set type/*from w w w.java 2 s . co m*/ mEMailIntent.setType("text/plain");//can select which APP will be used to send mail // open issue: cause warning for Key android.intent.extra.TEXT expected ArrayList String text_body = mContext.getResources().getString(R.string.eMail_body)// eMail text (body) + " " + Util.getStorageDirName(mContext) + " (UTF-8)" + Util.NEW_LINE + mEMailBodyString; // attachment: message List<String> filePaths = new ArrayList<String>(); for (int i = 0; i < attachmentFileName.length; i++) { String messagePath = "file:///" + Environment.getExternalStorageDirectory().getPath() + "/" + Util.getStorageDirName(mContext) + "/" + attachmentFileName[i];// message file name filePaths.add(messagePath); } // attachment: pictures if (picFileNameArray != null) { for (int i = 0; i < picFileNameArray.length; i++) { filePaths.add(picFileNameArray[i]); } } ArrayList<Uri> uris = new ArrayList<Uri>(); for (String file : filePaths) { Uri uri = Uri.parse(file); uris.add(uri); } mEMailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { strEMailAddr }) // eMail address .putExtra(Intent.EXTRA_SUBJECT, Util.getStorageDirName(mContext) + // eMail subject " " + mContext.getResources().getString(R.string.eMail_subject))// eMail subject .putExtra(Intent.EXTRA_TEXT, text_body) // eMail body (open issue) .putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); // multiple eMail attachment Log.v(getClass().getSimpleName(), "attachment " + Uri.parse("file name is:" + attachmentFileName)); getActivity().startActivityForResult( Intent.createChooser(mEMailIntent, getResources().getText(R.string.mail_chooser_title)), EMAIL_PAGES); }
From source file:com.landenlabs.all_devtool.TabPagerAdapter.java
public static void sharePage(String mediaPath) { Intent shareIntent = new Intent(Intent.ACTION_SEND); final String IMAGE_TYPE = "image/png"; shareIntent.setType(IMAGE_TYPE);//from w w w .j av a 2s .c o m Uri uri = Uri.parse(mediaPath); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); GlobalInfo.s_globalInfo.shareActionProvider.setShareIntent(shareIntent); }
From source file:com.github.dfa.diaspora_android.activity.ShareActivity.java
void handleSendImage(Intent intent) { final Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { // Update UI to reflect text being shared }//from ww w . j av a2 s .co m }
From source file:com.rp.podemu.SettingsActivity.java
public void sendDebug(View v) { String version;// ww w . j av a2 s . c om try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); version = pInfo.versionName; } catch (PackageManager.NameNotFoundException e) { version = "NA"; } String username = "dev.roman"; String domain = "gmail.com"; String uriText = "mailto:" + username + "@" + domain + "?subject=" + Uri.encode("PodEmu debug - V" + version) + "&body=" + Uri.encode("You can put additional description of the problem instead of this text."); Uri uri = Uri.parse(uriText); Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(uri); //intent.setAction(Intent.ACTION_ATTACH_DATA); Uri attachment = Uri.parse("file://" + PodEmuLog.getLogFileName()); intent.putExtra(Intent.EXTRA_STREAM, attachment); try { startActivity(Intent.createChooser(intent, "Send email")); } catch (android.content.ActivityNotFoundException e) { new AlertDialog.Builder(this).setTitle("Application not found").setMessage( "There is no application installed that can send emails. Please go to Android Market and install one.") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // continue with delete } }).setIcon(android.R.drawable.ic_dialog_alert).show(); } }
From source file:com.owncloud.android.files.FileOperationsHelper.java
public void sendDownloadedFile(OCFile file) { if (file != null) { String storagePath = file.getStoragePath(); String encodedStoragePath = WebdavUtils.encodePath(storagePath); Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); // set MimeType sendIntent.setType(file.getMimetype()); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath)); sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action // Show dialog, without the own app String[] packagesToExclude = new String[] { mFileActivity.getPackageName() }; DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file); chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG); } else {//from w w w . jav a 2 s . com Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); } }
From source file:de.dreier.mytargets.features.statistics.StatisticsActivity.java
void export() { MaterialDialog progress = new MaterialDialog.Builder(this).content(R.string.exporting).progress(true, 0) .show();/*ww w. jav a 2 s . c o m*/ new AsyncTask<Void, Void, Uri>() { @Override protected Uri doInBackground(Void... params) { try { return CsvExporter.export(getApplicationContext(), Stream.of(filteredRounds) .flatMap(p -> Stream.of(p.second)).map(Round::getId).collect(Collectors.toList())); } catch (IOException e) { e.printStackTrace(); return null; } } @Override protected void onPostExecute(Uri uri) { super.onPostExecute(uri); progress.dismiss(); if (uri != null) { Intent email = new Intent(Intent.ACTION_SEND); email.putExtra(Intent.EXTRA_STREAM, uri); email.setType("text/csv"); startActivity(Intent.createChooser(email, getString(R.string.send_exported))); } else { Snackbar.make(binding.getRoot(), R.string.exporting_failed, Snackbar.LENGTH_LONG).show(); } } }.execute(); }