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:com.android.dialer.voicemail.VoicemailPlaybackPresenter.java
private Intent getShareIntent(Uri voicemailFileUri) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, voicemailFileUri); shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.setType(mContext.getContentResolver().getType(voicemailFileUri)); return shareIntent; }
From source file:com.rsltc.profiledata.main.MainActivity.java
private void exportFile(List<JSONObject> jsonObjects, String dataset_name) { final String date = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.getDefault()).format(new Date()); final String filename = String.format("%s_%s.txt", dataset_name, date); final String directory = Environment.getExternalStorageDirectory().getAbsolutePath() + "/AndroidTesting/"; final File logfile = new File(directory, filename); final File logPath = logfile.getParentFile(); if (!logPath.isDirectory() && !logPath.mkdirs()) { Log.e("SensorDashbaord", "Could not create directory for log files"); }//from w w w . j av a 2s .c o m try { FileWriter filewriter = new FileWriter(logfile); BufferedWriter bw = new BufferedWriter(filewriter); // for (JSONObject object : jsonObjects) { bw.write(jsonObjects.toString()); // } bw.flush(); bw.close(); Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("*/*"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, dataset_name + ".csv"); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(logfile)); startActivity(Intent.createChooser(emailIntent, "Send mail...")); Log.i(TAG, "export finished!"); } catch (IOException ioe) { Log.e(TAG, "IOException while writing Logfile"); Log.e("Enias", ioe.getMessage()); } }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
public void loadFromIntents() { Intent intent = getIntent();/*from w w w . j ava 2 s . c o m*/ String action = intent.getAction(); String type = intent.getType(); System.out.println("Intentoso " + action + " type " + type); if (Intent.ACTION_SEND.equals(action) && type != null) { if (type.startsWith("image/")) { setBackgroundUri((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)); } } }
From source file:com.github.dfa.diaspora_android.activity.MainActivity.java
/** * Share an image shared to the app via diaspora * * @param intent shareImageIntent/*from w w w . ja v a 2 s .co m*/ */ //TODO: Implement some day private void handleSendImage(Intent intent) { AppLog.i(this, "handleSendImage()"); final Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { AppLog.v(this, "imageUri is not null. Handle shared image"); } else { AppLog.w(this, "imageUri is null. Cannot precede."); } Toast.makeText(this, "Not yet implemented.", Toast.LENGTH_SHORT).show(); }
From source file:au.com.infiniterecursion.vidiom.utils.PublishingUtils.java
public void launchEmailIntentWithCurrentVideo(final Activity activity, final String latestVideoFile_absolutepath) { Log.d(TAG, "launchEmailIntentWithCurrentVideo starting"); Intent i = new Intent(Intent.ACTION_SEND); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // XXX hardcoded video mimetype i.setType("video/mp4"); i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + latestVideoFile_absolutepath)); activity.startActivity(i);//from w w w . j a v a 2 s .co m }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java
private void archiveWalletBackup(@Nonnull final File file) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.export_keys_dialog_mail_subject)); intent.putExtra(Intent.EXTRA_TEXT, makeEmailText(getString(R.string.export_keys_dialog_mail_text))); intent.setType(Constants.MIMETYPE_WALLET_BACKUP); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); try {//from ww w .jav a 2 s . c om startActivity(Intent.createChooser(intent, getString(R.string.export_keys_dialog_mail_intent_chooser))); log.info("invoked chooser for archiving wallet backup"); } catch (final Exception x) { longToast(R.string.export_keys_dialog_mail_intent_failed); log.error("archiving wallet backup failed", x); } }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
private void sendFiles(final ArrayList<Uri> filesToSend) { // send files in a separate task without a dialog so we don't leave the previous progress dialog behind on // screen rotation - this is a bit of a hack, but it works runImmediateBackgroundTask(new BackgroundRunnable() { @Override/*from w w w . j a va 2 s. co m*/ public int getTaskId() { return 0; } @Override public boolean getShowDialog() { return false; } @Override public void run() { if (filesToSend == null || filesToSend.size() <= 0) { return; } // ensure files are accessible to send - bit of a last-ditch effort for when temp is on internal storage for (Uri fileUri : filesToSend) { IOUtilities.setFullyPublic(new File(fileUri.getPath())); } // also see: http://stackoverflow.com/questions/2344768/ // could use application/smil+xml (or html), or video/quicktime, but then there's no bluetooth option final Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); sendIntent.setType(getString(R.string.export_mime_type)); sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, filesToSend); final Intent chooserIntent = Intent.createChooser(sendIntent, getString(R.string.export_narrative_title)); // an extra activity at the start of the list that moves exported files to SD, but only if SD available if (IOUtilities.externalStorageIsWritable()) { final Intent targetedShareIntent = new Intent(MediaPhoneActivity.this, SaveNarrativeActivity.class); targetedShareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); targetedShareIntent.setType(getString(R.string.export_mime_type)); targetedShareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, filesToSend); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[] { targetedShareIntent }); } startActivity(chooserIntent); // single task mode; no return value given } }); }
From source file:me.tb.player.SkeletonActivity.java
public static void createInstagramIntent(Context context, String type, String mediaPath, String caption) { // Create the new Intent using the 'Send' action. Intent share = new Intent(Intent.ACTION_SEND); // Set the MIME type share.setType(type);/*w w w. j a v a 2s . c om*/ // Create the URI from the media File media = new File(mediaPath); Uri uri = Uri.fromFile(media); // Add the URI and the caption to the Intent. share.putExtra(Intent.EXTRA_STREAM, uri); share.putExtra(Intent.EXTRA_TEXT, caption); share.putExtra(Intent.EXTRA_SUBJECT, "Check this out"); share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Broadcast the Intent. context.startActivity(Intent.createChooser(share, "Share to")); }
From source file:com.android.gallery3d.filtershow.FilterShowActivity.java
private Intent getDefaultShareIntent() { Intent intent = new Intent(Intent.ACTION_SEND); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType(SharedImageProvider.MIME_TYPE); mSharedOutputFile = SaveImage.getNewFile(this, MasterImage.getImage().getUri()); Uri uri = Uri.withAppendedPath(SharedImageProvider.CONTENT_URI, Uri.encode(mSharedOutputFile.getAbsolutePath())); intent.putExtra(Intent.EXTRA_STREAM, uri); return intent; }
From source file:com.odoo.core.orm.OModel.java
public void exportDB() { FileChannel source;/*from w ww. j a va2s .c o m*/ FileChannel destination; String currentDBPath = getDatabaseLocalPath(); String backupDBPath = OStorageUtils.getDirectoryPath("file") + "/" + getDatabaseName(); File currentDB = new File(currentDBPath); File backupDB = new File(backupDBPath); try { source = new FileInputStream(currentDB).getChannel(); destination = new FileOutputStream(backupDB).getChannel(); destination.transferFrom(source, 0, source.size()); source.close(); destination.close(); String subject = "Database Export: " + getDatabaseName(); Uri uri = Uri.fromFile(backupDB); Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.setType("message/rfc822"); mContext.startActivity(intent); } catch (IOException e) { e.printStackTrace(); } }