List of usage examples for android.content Intent ACTION_SEND_MULTIPLE
String ACTION_SEND_MULTIPLE
To view the source code for android.content Intent ACTION_SEND_MULTIPLE.
Click Source Link
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);// w w w .jav a 2s .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); intent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); }//from w ww . ja v a2 s . c o m return intent; }
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 ava 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 Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);//from w ww . j av a2 s . co 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; }
From source file:Main.java
public static Intent share(String text, String mimeType, Uri... attachments) { final Intent intent = new Intent(); intent.setType(mimeType);/*from www .j ava2 s . 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); intent.putExtra(Intent.EXTRA_STREAM, attachments[0]); } return intent; }
From source file:Main.java
/** * Send an email via available mail activity * //from w ww .jav a 2 s. c o m * @param context the app context * @param to the email address send to * @param subject the email subject * @param body the email body * @param attachments the uris for attachments */ public static void sendEmail(Context context, String to, String subject, String body, Uri... attachments) { Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); emailIntent.setType("plain/text"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && attachments.length != 0) { ArrayList<Uri> uris = new ArrayList<Uri>(); for (int i = 0; i < attachments.length; i++) uris.add(attachments[i]); emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } context.startActivity(Intent.createChooser(emailIntent, null)); }
From source file:at.jclehner.appopsxposed.BugReportBuilder.java
public static void buildAndSend(final Context context) { if (!SU.available()) { Toast.makeText(context, R.string.toast_needs_root, Toast.LENGTH_SHORT).show(); return;/* ww w . j ava2s .c o m*/ } Toast.makeText(context, R.string.building_toast, Toast.LENGTH_LONG).show(); final BugReportBuilder brb = new BugReportBuilder(context); new AsyncTask<Void, Void, Uri>() { @Override protected Uri doInBackground(Void... params) { return brb.build(); } @Override protected void onPostExecute(Uri result) { final ArrayList<Parcelable> uris = new ArrayList<Parcelable>(); uris.add(result); final Intent target = new Intent(Intent.ACTION_SEND_MULTIPLE); target.setType("text/plain"); target.putExtra(Intent.EXTRA_SUBJECT, "[REPORT][AppOpsXposed " + Util.getAoxVersion(context) + "] " + Build.FINGERPRINT); target.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); //target.putExtra(Intent.EXTRA_STREAM, result); target.putExtra(Intent.EXTRA_TEXT, "!!! BUG REPORTS WITHOUT ADDITIONAL INFO WILL BE IGNORED !!!"); //target.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); final Intent intent = Intent.createChooser(target, null); //intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(intent); } }.execute(); }
From source file:org.sufficientlysecure.keychain.ui.EncryptFilesActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setFullScreenDialogClose(Activity.RESULT_OK, false); Intent intent = getIntent();/*from www. j a v a 2 s . c o m*/ String action = intent.getAction(); String type = intent.getType(); ArrayList<Uri> uris = new ArrayList<>(); if (intent.getData() != null) { uris.add(intent.getData()); } // When sending to OpenKeychain Encrypt via share menu if (Intent.ACTION_SEND.equals(action) && type != null) { // Files via content provider, override uri and action uris.clear(); uris.add(intent.<Uri>getParcelableExtra(Intent.EXTRA_STREAM)); } if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); } if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); EncryptFilesFragment encryptFragment = EncryptFilesFragment.newInstance(uris); transaction.replace(R.id.encrypt_file_container, encryptFragment); transaction.commit(); } }
From source file:org.stenerud.kscrash.KSCrashReportFilterEmail.java
@Override public void filterReports(List reports, CompletionCallback completionCallback) throws KSCrashReportFilteringFailedException { ArrayList<Uri> attachments = new ArrayList<>(); String authority = BuildConfig.APPLICATION_ID + ".provider"; for (Object report : reports) { attachments.add(FileProvider.getUriForFile(context, authority, (File) report)); }// w ww . ja v a2 s. c o m Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType("*/*"); // TODO: Why does this fail? // intent.setData(Uri.parse("mailto:")); intent.putExtra(Intent.EXTRA_EMAIL, recipients.toArray()); intent.putExtra(Intent.EXTRA_SUBJECT, subject); // Workaround for framework bug ArrayList<String> text = new ArrayList<>(); text.add(message); intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_STREAM, attachments); if (intent.resolveActivity(context.getPackageManager()) != null) { context.startActivity(intent); } completionCallback.onCompletion(reports); }
From source file:com.krayzk9s.imgurholo.activities.ImgurLinkActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); destroyed = false;// w w w . j av a 2 s . c o m if (getActionBar() != null) getActionBar().setDisplayHomeAsUpEnabled(true); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); Log.d("New Intent", intent.toString()); if (Intent.ACTION_SEND.equals(action) && type != null) { if (type.startsWith("image/")) { Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); Intent serviceIntent = new Intent(this, UploadService.class); if (intent.getExtras() == null) finish(); serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM")); startService(serviceIntent); finish(); } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { Log.d("sending", "sending multiple"); Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); Intent serviceIntent = new Intent(this, UploadService.class); serviceIntent.putParcelableArrayListExtra("images", list); startService(serviceIntent); finish(); } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null && intent.getData().toString().startsWith("http://imgur.com/a")) { String uri = intent.getData().toString(); album = uri.split("/")[4]; Log.d("album", album); Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM); fetcher.execute(); } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://imgur.com/gallery/")) { String uri = intent.getData().toString(); final String album = uri.split("/")[4]; if (album.length() == 5) { Log.d("album", album); Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM); fetcher.execute(); } else if (album.length() == 7) { Log.d("image", album); Fetcher fetcher = new Fetcher(this, "/3/gallery/image/" + album, ApiCall.GET, null, apiCall, IMAGE); fetcher.execute(); } } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://i.imgur")) { String uri = intent.getData().toString(); final String image = uri.split("/")[3].split("\\.")[0]; Log.d("image", image); Fetcher fetcher = new Fetcher(this, "/3/image/" + image, ApiCall.GET, null, apiCall, IMAGE); fetcher.execute(); } }