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:Main.java
private static void shareAct(Activity act, String fileName, String text) { Uri uri = null;/*from w w w . j a v a 2 s . co m*/ try { FileInputStream input = act.openFileInput(fileName); Bitmap bitmap = BitmapFactory.decodeStream(input); uri = Uri.parse(MediaStore.Images.Media.insertImage(act.getContentResolver(), bitmap, null, null)); input.close(); } catch (Exception e) { e.printStackTrace(); } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpeg"); act.startActivity(Intent.createChooser(shareIntent, act.getTitle())); }
From source file:Main.java
@NonNull public static Intent sendEmail(@NonNull String[] to, @NonNull String subject, @NonNull String body, @Nullable List<Uri> attachments) { final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); }/*from ww w. j a v a 2 s.co m*/ return intent; }
From source file:Main.java
public static Intent newSendMultipleAttachmentsIntent(String emailAddress, String subject, String contentBody, ArrayList<Uri> uris) { final Intent ei = new Intent(Intent.ACTION_SEND_MULTIPLE); ei.setType("plain/text"); ei.putExtra(Intent.EXTRA_EMAIL, new String[] { emailAddress }); ei.putExtra(Intent.EXTRA_SUBJECT, subject); //ei.putExtra(Intent.EXTRA_TEXT, contentBody); //fix for ClassCastException with Intent.EXTRA_TEXT : https://code.google.com/p/android/issues/detail?id=38303 //: use list of string not a string ArrayList<String> extra_text = new ArrayList<String>(); extra_text.add(contentBody);/*ww w.jav a 2 s. c o m*/ ei.putExtra(Intent.EXTRA_TEXT, extra_text); ei.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); return ei; }
From source file:Main.java
@NonNull public static Intent sendEmail(@NonNull String[] to, @NonNull String subject, @NonNull String body, @Nullable List<Uri> attachments) { final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_SUBJECT, subject); final ArrayList<CharSequence> extraText = new ArrayList<>(1); extraText.add(body);//from w w w . j a v a 2 s . c o m intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, extraText); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); } return intent; }
From source file:Main.java
public static void shareFile(Context context, String title, String filePath) { Intent intent = new Intent(Intent.ACTION_SEND); Uri uri = Uri.parse("file://" + filePath); intent.setType("*/*"); intent.putExtra(Intent.EXTRA_STREAM, uri); context.startActivity(Intent.createChooser(intent, title)); }
From source file:Main.java
/** * Creates a intent with an image/*from www .j a va2 s . c om*/ * * @param image * @return */ public static Intent createIntentFromImage(File image) { Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/*"); return share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image)); }
From source file:Main.java
public static void callSysShare(Context context, String chooserTitle, String shareTitle, String shareText, String mime, Uri uri) {// w w w . j a v a 2 s .c o m Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_TEXT, shareText); intent.putExtra(Intent.EXTRA_SUBJECT, shareTitle); intent.setType(mime); if (uri != null) { intent.putExtra(Intent.EXTRA_STREAM, uri); } context.startActivity(Intent.createChooser(intent, chooserTitle)); }
From source file:com.duy.ascii.sharedcode.ShareUtil.java
public static void shareImage(Context context, File file) { Uri uri;//from w w w .j a v a 2 s. c o m if (Build.VERSION.SDK_INT >= 24) { uri = FileProvider.getUriForFile(context, context.getPackageName() + ".provider", file); } else { uri = Uri.fromFile(file); } Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType("image/*"); context.startActivity(Intent.createChooser(intent, "Share image via")); }
From source file:com.googlecode.eyesfree.brailleback.WebViewDialog.java
public static Intent getIntent(Context context, int titleResId, String url) { Intent intent = new Intent(context, WebViewDialog.class); intent.putExtra(Intent.EXTRA_TITLE, titleResId); intent.putExtra(Intent.EXTRA_STREAM, url); return intent; }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);/* w w w . j a v a2s .c o m*/ if (attachments.length > 1) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); final ArrayList<CharSequence> textExtra = new ArrayList<>(); textExtra.add(text); intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, textExtra); final ArrayList<Parcelable> uris = new ArrayList<>(); Collections.addAll(uris, attachments); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } else { intent.setAction(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, text); if (attachments.length > 0) { intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } } return intent; }