android.content.Intent#ACTION_SEND_MULTIPLE源码实例Demo

下面列出了android.content.Intent#ACTION_SEND_MULTIPLE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: QtAndroidTools   文件: AndroidTools.java
public int getActivityAction()
{
    final String ActionValue = mActivityInstance.getIntent().getAction();
    int ActionId = ACTION_NONE;

    if(ActionValue != null)
    {
        switch(ActionValue)
        {
            case Intent.ACTION_SEND:
                ActionId = ACTION_SEND;
                break;
            case Intent.ACTION_SEND_MULTIPLE:
                ActionId = ACTION_SEND_MULTIPLE;
                break;
            case Intent.ACTION_PICK:
                ActionId = ACTION_PICK;
                break;
        }
    }

    return ActionId;
}
 
源代码2 项目: edslite   文件: ActionSendTask.java
public static void sendFiles(Context context, ArrayList<Uri> uris, String mime, ClipData clipData)
{
	if(uris == null || uris.isEmpty())
		return;

	Intent actionIntent = new Intent(uris.size() > 1 ? Intent.ACTION_SEND_MULTIPLE : Intent.ACTION_SEND);
	actionIntent.setType(mime == null ? "*/*" : mime);
	if (uris.size() > 1)
		actionIntent.putExtra(Intent.EXTRA_STREAM, uris);
	else
		actionIntent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && clipData!=null)
	{
		actionIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
		actionIntent.setClipData(clipData);
	}

	Intent startIntent = Intent.createChooser(actionIntent, context.getString(R.string.send_files_to));
	startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	context.startActivity(startIntent);
}
 
源代码3 项目: YalpStore   文件: BugReportSenderEmail.java
private Intent getEmailIntent() {
    Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    String developerEmail = context.getString(R.string.about_developer_email);
    emailIntent.setData(Uri.fromParts("mailto", developerEmail, null));
    emailIntent.setType("text/plain");
    emailIntent.setType("message/rfc822");
    emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {developerEmail});
    if (!TextUtils.isEmpty(userMessage)) {
        emailIntent.putExtra(Intent.EXTRA_TEXT, userMessage);
    }
    emailIntent.putExtra(
        Intent.EXTRA_SUBJECT,
        context.getString(
            TextUtils.isEmpty(stackTrace) ? R.string.email_subject_feedback : R.string.email_subject_crash_report,
            BuildConfig.APPLICATION_ID,
            BuildConfig.VERSION_NAME
        )
    );
    ArrayList<Uri> uris = new ArrayList<>();
    for (File file: files) {
        uris.add(getUri(file));
    }
    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    return emailIntent;
}
 
源代码4 项目: openlauncher   文件: ShareUtil.java
/**
 * Share the given files as stream with given mime-type
 *
 * @param files    The files to share
 * @param mimeType The files mime type. Usally * / * is the best option
 */
public boolean shareStreamMultiple(final Collection<File> files, final String mimeType) {
    ArrayList<Uri> uris = new ArrayList<>();
    for (File file : files) {
        File uri = new File(file.toString());
        uris.add(FileProvider.getUriForFile(_context, getFileProviderAuthority(), file));
    }

    try {
        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.setType(mimeType);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        showChooser(intent, null);
        return true;
    } catch (Exception e) { // FileUriExposed(API24) / IllegalArgument
        return false;
    }
}
 
源代码5 项目: mage-android   文件: ObservationShareTask.java
@Override
protected void onPostExecute(ArrayList<Uri> uris) {
    if (progressDialog != null) {
        progressDialog.dismiss();
    }

    if (uris.size() != observation.getAttachments().size()) {
        Toast toast = Toast.makeText(activity, "One or more attachments failed to attach", Toast.LENGTH_LONG);
        toast.show();
    }

    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, observation.getEvent().getName() + " MAGE Observation");
    intent.putExtra(Intent.EXTRA_TEXT, observationText(observation));
    intent.putExtra(Intent.EXTRA_STREAM, uris);
    activity.startActivity(Intent.createChooser(intent, "Share Observation"));
}
 
源代码6 项目: TelePlus-Android   文件: SettingsActivity.java
private void sendLogs() {
    try {
        ArrayList<Uri> uris = new ArrayList<>();
        File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null);
        File dir = new File(sdCard.getAbsolutePath() + "/logs");
        File[] files = dir.listFiles();

        for (File file : files) {
            if (Build.VERSION.SDK_INT >= 24) {
                uris.add(FileProvider.getUriForFile(getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", file));
            } else {
                uris.add(Uri.fromFile(file));
            }
        }

        if (uris.isEmpty()) {
            return;
        }
        Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
        if (Build.VERSION.SDK_INT >= 24) {
            i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
        i.setType("message/rfc822");
        i.putExtra(Intent.EXTRA_EMAIL, "");
        i.putExtra(Intent.EXTRA_SUBJECT, "last logs");
        i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        getParentActivity().startActivityForResult(Intent.createChooser(i, "Select email application."), 500);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
private static void sendEmailWithError(Context activityContext, EmailErrorReport emailErrorReport) {
    Intent sendEmail = new Intent(Intent.ACTION_SEND_MULTIPLE);
    sendEmail.setType("message/rfc822");

    emailErrorReport.configureRecipients(sendEmail);
    emailErrorReport.configureSubject(sendEmail);
    emailErrorReport.configureMessage(sendEmail);
    emailErrorReport.configureAttachments(sendEmail, activityContext);

    try {
        activityContext.startActivity(Intent.createChooser(sendEmail, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(activityContext, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }
}
 
源代码8 项目: TelePlus-Android   文件: SettingsActivity.java
private void sendLogs() {
    try {
        ArrayList<Uri> uris = new ArrayList<>();
        File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null);
        File dir = new File(sdCard.getAbsolutePath() + "/logs");
        File[] files = dir.listFiles();

        for (File file : files) {
            if (Build.VERSION.SDK_INT >= 24) {
                uris.add(FileProvider.getUriForFile(getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", file));
            } else {
                uris.add(Uri.fromFile(file));
            }
        }

        if (uris.isEmpty()) {
            return;
        }
        Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
        if (Build.VERSION.SDK_INT >= 24) {
            i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        }
        i.setType("message/rfc822");
        i.putExtra(Intent.EXTRA_EMAIL, "");
        i.putExtra(Intent.EXTRA_SUBJECT, "last logs");
        i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        getParentActivity().startActivityForResult(Intent.createChooser(i, "Select email application."), 500);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码9 项目: fitnotifications   文件: DebugLog.java
public Intent emailLogIntent(Context context, String logcat) {
    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("application/octet-stream");

    String subject = "Fit Notification Logs";
    ArrayList<Uri> attachments = new ArrayList<>();
    attachments.add(FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", mLogFile));
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
    intent.putExtra(Intent.EXTRA_TEXT, logcat);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);

    return intent;
}
 
源代码10 项目: haven   文件: EventActivity.java
private void shareEvent ()
{
    String title = "Phoneypot: " + mEvent.getStartTime().toLocaleString();

    //need to "send multiple" to get more than one attachment
    final Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("text/plain");

    emailIntent.putExtra(Intent.EXTRA_SUBJECT, title);
    emailIntent.putExtra(Intent.EXTRA_TEXT, generateLog());
    //has to be an ArrayList
    ArrayList<Uri> uris = new ArrayList<>();
    //convert from paths to Android friendly Parcelable Uri's
    for (EventTrigger trigger : eventTriggerList)
    {
        // ignore triggers for which we do not have valid file/file-paths
        if (trigger.getMimeType() == null || trigger.getPath() == null)
            continue;

        File fileIn = new File(trigger.getPath());
        Uri u = Uri.fromFile(fileIn);
        uris.add(u);
    }

    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    startActivity(Intent.createChooser(emailIntent, getString(R.string.share_event_action)));
}
 
private void shareProject() {
    String savedFilePath;
    savedFilePath = saveProject();
    if (savedFilePath == null || savedFilePath.length() == 0) {
        return;
    }
    Uri fileUri = Uri.fromFile(new File(savedFilePath));
    ArrayList<Uri> uris = new ArrayList<>();
    Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    sendIntent.setType("application/zip");
    uris.add(fileUri);
    sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    startActivity(Intent.createChooser(sendIntent, null));
}
 
源代码12 项目: AndroidUtilCode   文件: IntentUtils.java
/**
 * Return the intent of share images.
 *
 * @param content The content.
 * @param uris    The uris of image.
 * @return the intent of share image
 */
public static Intent getShareImageIntent(final String content, final ArrayList<Uri> uris) {
    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.putExtra(Intent.EXTRA_TEXT, content);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    intent.setType("image/*");
    return getIntent(intent, true);
}
 
源代码13 项目: EasyFeedback   文件: FeedbackActivity.java
public void sendEmail(String body) {

        Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        emailIntent.setType("text/plain");
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailId});
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_mail_subject, getAppLabel()));
        emailIntent.putExtra(Intent.EXTRA_TEXT, body);

        ArrayList<Uri> uris = new ArrayList<>();


        if (withInfo) {
            Uri deviceInfoUri = createFileFromString(deviceInfo, getString(R.string.file_name_device_info));
            uris.add(deviceInfoUri);

            Uri logUri = createFileFromString(LOG_TO_STRING, getString(R.string.file_name_device_log));
            uris.add(logUri);
        }

        if (realPath != null) {
            Uri uri = FileProvider.getUriForFile(
                    this,
                    getApplicationContext()
                            .getPackageName() + ".provider", new File(realPath));
            //Uri uri = Uri.parse("file://" + realPath);
            uris.add(uri);
        }
        emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Utils.createEmailOnlyChooserIntent(this, emailIntent, getString(R.string.send_feedback_two)));
    }
 
源代码14 项目: Document-Scanner   文件: GalleryGridActivity.java
public void shareImages() {

        final Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        shareIntent.setType("image/jpg");

        ArrayList<Uri> filesUris = new ArrayList<>();

        for (String i : myThumbAdapter.getSelectedFiles() ) {
            filesUris.add(Uri.parse("file://" + i));
        }
        shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, filesUris);

        startActivity(Intent.createChooser(shareIntent, getString(R.string.share_snackbar)));
    }
 
源代码15 项目: telescope   文件: EmailLens.java
@Override protected Intent doInBackground(Void... params) {
  Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
  intent.setType("message/rfc822");

  if (subject != null) {
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
  }

  if (addresses != null) {
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
  }

  String body = getBody();
  if (body != null) {
    intent.putExtra(Intent.EXTRA_TEXT, body);
  }

  Set<Uri> additionalAttachments = getAdditionalAttachments();
  ArrayList<Uri> attachments = new ArrayList<>(additionalAttachments.size() + 1 /* screen */);
  if (!additionalAttachments.isEmpty()) {
    attachments.addAll(additionalAttachments);
  }
  if (screenshot != null) {
    attachments.add(TelescopeFileProvider.getUriForFile(context, screenshot));
  }

  if (!attachments.isEmpty()) {
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  }

  return intent;
}
 
源代码16 项目: debugdrawer   文件: BugReportLens.java
private void submitReport(Report report, File logs) {
	DisplayMetrics dm = context.getResources().getDisplayMetrics();
	String densityBucket = getDensityString(dm);

	Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
	intent.setType("message/rfc822");
	// TODO: intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
	intent.putExtra(Intent.EXTRA_SUBJECT, report.title);

	StringBuilder body = new StringBuilder();
	if (!Strings.isBlank(report.description)) {
		body.append("{panel:title=Description}\n").append(report.description).append("\n{panel}\n\n");
	}

	// TODO: Change to dyanimic BuildConfig
	body.append("{panel:title=App}\n");
	body.append("Version: ").append(BuildConfig.VERSION_NAME).append('\n');
	body.append("Version code: ").append(BuildConfig.VERSION_CODE).append('\n');
	body.append("{panel}\n\n");

	body.append("{panel:title=Device}\n");
	body.append("Make: ").append(Build.MANUFACTURER).append('\n');
	body.append("Model: ").append(Build.MODEL).append('\n');
	body.append("Resolution: ")
			.append(dm.heightPixels)
			.append("x")
			.append(dm.widthPixels)
			.append('\n');
	body.append("Density: ")
			.append(dm.densityDpi)
			.append("dpi (")
			.append(densityBucket)
			.append(")\n");
	body.append("Release: ").append(Build.VERSION.RELEASE).append('\n');
	body.append("API: ").append(Build.VERSION.SDK_INT).append('\n');
	body.append("{panel}");

	intent.putExtra(Intent.EXTRA_TEXT, body.toString());

	ArrayList<Uri> attachments = new ArrayList<>();
	if (screenshot != null && report.includeScreenshot) {
		attachments.add(Uri.fromFile(screenshot));
	}
	if (logs != null) {
		attachments.add(Uri.fromFile(logs));
	}

	if (!attachments.isEmpty()) {
		intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
	}

	Intents.maybeStartActivity(context, intent);
}
 
源代码17 项目: u2020-mvp   文件: BugReportLens.java
private void submitReport(BugReportView.Report report, File logs) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics();
    String densityBucket = getDensityString(dm);

    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("message/rfc822");
    // TODO: intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]" });
    intent.putExtra(Intent.EXTRA_SUBJECT, report.title);

    StringBuilder body = new StringBuilder();
    if (!Strings.isBlank(report.description)) {
        body.append("{panel:title=Description}\n").append(report.description).append("\n{panel}\n\n");
    }

    body.append("{panel:title=App}\n");
    body.append("Version: ").append(BuildConfig.VERSION_NAME).append('\n');
    body.append("Version code: ").append(BuildConfig.VERSION_CODE).append('\n');
    body.append("{panel}\n\n");

    body.append("{panel:title=Device}\n");
    body.append("Make: ").append(Build.MANUFACTURER).append('\n');
    body.append("Model: ").append(Build.MODEL).append('\n');
    body.append("Resolution: ")
            .append(dm.heightPixels)
            .append("x")
            .append(dm.widthPixels)
            .append('\n');
    body.append("Density: ")
            .append(dm.densityDpi)
            .append("dpi (")
            .append(densityBucket)
            .append(")\n");
    body.append("Release: ").append(Build.VERSION.RELEASE).append('\n');
    body.append("API: ").append(Build.VERSION.SDK_INT).append('\n');
    body.append("{panel}");

    intent.putExtra(Intent.EXTRA_TEXT, body.toString());

    ArrayList<Uri> attachments = new ArrayList<>();
    if (screenshot != null && report.includeScreenshot) {
        attachments.add(Uri.fromFile(screenshot));
    }
    if (logs != null) {
        attachments.add(Uri.fromFile(logs));
    }

    if (!attachments.isEmpty()) {
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
    }

    Intents.maybeStartActivity(context, intent);
}
 
源代码18 项目: explorer   文件: MainActivity.java
private void actionSend() {

        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);

        intent.setType("*/*");

        ArrayList<Uri> uris = new ArrayList<>();

        for (File file : adapter.getSelectedItems()) {

            if (file.isFile()) uris.add(Uri.fromFile(file));
        }

        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

        startActivity(intent);
    }
 
源代码19 项目: aptoide-client-v8   文件: SendFeedbackFragment.java
private void sendFeedback() {
  if (isContentValid()) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("message/rfc822");

    final AptoideApplication application =
        (AptoideApplication) getContext().getApplicationContext();
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {
        application.getFeedbackEmail()
    });
    final String cachePath = getContext().getApplicationContext()
        .getCacheDir()
        .getPath();
    unManagedSubscription = installedRepository.getInstalled(getContext().getPackageName())
        .first()
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(installed1 -> {
          String versionName = "";
          if (installed1 != null) {
            versionName = installed1.getVersionName();
          }

          emailIntent.putExtra(Intent.EXTRA_SUBJECT,
              "[Feedback]-" + versionName + ": " + subgectEdit.getText()
                  .toString());
          emailIntent.putExtra(Intent.EXTRA_TEXT, messageBodyEdit.getText()
              .toString());
          //attach screenshots and logs
          if (logsAndScreenshotsCb.isChecked()) {
            ArrayList<Uri> uris = new ArrayList<Uri>();
            if (screenShotPath != null) {
              File ss = new File(screenShotPath);
              uris.add(getUriFromFile(ss));
            }
            File logs = AptoideUtils.SystemU.readLogs(cachePath, LOGS_FILE_NAME,
                cardId != null ? cardId : aptoideNavigationTracker.getPrettyScreenHistory());

            if (logs != null) {
              uris.add(getUriFromFile(logs));
            }

            emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
          }
          try {
            //holy moly
            getActivity().getSupportFragmentManager()
                .beginTransaction()
                .remove(this)
                .commit();
            startActivity(emailIntent);
            getActivity().onBackPressed();
            //				Analytics.SendFeedback.sendFeedback();
          } catch (ActivityNotFoundException ex) {
            ShowMessage.asSnack(getView(), R.string.feedback_no_email);
          }
        }, throwable -> crashReport.log(throwable));
  } else {
    ShowMessage.asSnack(getView(), R.string.feedback_not_valid);
  }
}
 
源代码20 项目: android_maplibui   文件: ExportGPXTask.java
@Override
protected void onPostExecute(Void aVoid) {
    super.onPostExecute(aVoid);

    ControlHelper.unlockScreenOrientation(mActivity);
    if (mProgress != null)
        mProgress.dismiss();

    if (mIsCanceled)
        return;

    String text = mActivity.getString(R.string.not_enough_points);
    if (mNoPoints > 0)
        if (mUris.size() > 0)
            Toast.makeText(mActivity, text + " (" + mNoPoints + ")", Toast.LENGTH_LONG).show();
        else
            Toast.makeText(mActivity, text, Toast.LENGTH_LONG).show();

    if (mUris.size() == 0)
        return;

    Intent shareIntent = new Intent();
    String type = "application/gpx+xml";
    String action = Intent.ACTION_SEND;

    if (mUris.size() > 1)
        action = Intent.ACTION_SEND_MULTIPLE;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(mActivity);
        for (Uri uri : mUris)
            builder.addStream(uri);
        shareIntent = builder.setType(type).getIntent().setAction(action).setType(type).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } else {
        shareIntent = Intent.createChooser(shareIntent, mActivity.getString(R.string.menu_share));
        shareIntent.setType(type);
        shareIntent.setAction(action);
        shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (mUris.size() > 1)
            shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, mUris);
        else
            shareIntent.putExtra(Intent.EXTRA_STREAM, mUris.get(0));
    }

    try {
        mActivity.startActivity(shareIntent);
    } catch (ActivityNotFoundException e) {
        notFound(mActivity);
    }
}
 
 方法所在类
 同类方法