Java Code Examples for android.content.Intent.ACTION_SEND_MULTIPLE

The following are Jave code examples for showing how to use ACTION_SEND_MULTIPLE of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Bridge   File: FileSaveService.java   View Source Code Vote up 8 votes
@Override
protected void onHandleIntent(Intent intent) {
    if (intent == null || !intent.hasExtra(Intent.EXTRA_STREAM)) {
        return;
    }

    switch (intent.getAction()) {
        case Intent.ACTION_SEND:
        case Intent.ACTION_SEND_MULTIPLE:
            handleSaveFile(intent);
            break;
        case ACTION_CLEAR_CACHE:
            FileUtils.clearCache(this);
            break;
    }
}
 
Example 2
Project: Cluttr   File: Media.java   View Source Code Vote up 7 votes
public static void share(Context context, String album) {

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

        Realm realm = Realm.getDefaultInstance();
        for(MediaItem item : realm.where(Album.class).equalTo("path", album).findFirst().getMedia().where().equalTo("isSelected",true).findAll()) {
            File file = new File(item.getPath());
            Uri uri = Uri.fromFile(file);
            files.add(uri);
        }

        final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.setType("image/*");
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);

        realm.beginTransaction();
        realm.where(Album.class).equalTo("path", album).findFirst().clearMediaSelection();
        realm.commitTransaction();
        realm.close();

        context.startActivity(Intent.createChooser(intent, "Share"));
    }
 
Example 3
Project: airgram   File: SettingsActivity.java   View Source Code Vote up 7 votes
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) {
            uris.add(Uri.fromFile(file));
        }

        if (uris.isEmpty()) {
            return;
        }
        Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE);
        i.setType("message/rfc822");
        i.putExtra(Intent.EXTRA_EMAIL, new String[]{BuildVars.SEND_LOGS_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();
    }
}
 
Example 4
Project: Android-FileBrowser-FilePicker   File: FileIO.java   View Source Code Vote up 7 votes
public void shareMultipleFiles(List<FileItem> filesToBeShared){

        ArrayList<Uri> uris = new ArrayList<>();
        for(FileItem file: filesToBeShared){
            uris.add(Uri.fromFile(file.getFile()));
        }
        final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.setType("*/*");
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        PackageManager manager = mContext.getPackageManager();
        List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
        if (infos.size() > 0) {
            mContext.startActivity(Intent.createChooser(intent, mContext.getString(R.string.share)));
        } else {
            UIUtils.ShowToast("No app found to handle sharing",mContext);
        }
    }
 
Example 5
Project: haven   File: EventActivity.java   View Source Code Vote up 7 votes
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 : mEvent.getEventTriggers())
    {
        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)));
}
 
Example 6
Project: BaseCore   File: LocalShareUtils.java   View Source Code Vote up 7 votes
/**
 * 分享多图到指定软件,QQ,微信,新浪微博
 */
public static void ShareImagesToAssignAPP(Context context, List<File> fileList,String type) {
    boolean found = false;
    ArrayList<Uri> uriList = new ArrayList<>();
    Intent share = new Intent(Intent.ACTION_SEND_MULTIPLE);
    share.setType("image/*");
    for (int i = 0; i < fileList.size(); i++) {
        uriList.add(Uri.fromFile(fileList.get(i)));
    }
    List<ResolveInfo> resInfo = context.getPackageManager().queryIntentActivities(share, 0);
    if (!resInfo.isEmpty()){
        for (ResolveInfo info : resInfo) {
            if (info.activityInfo.packageName.toLowerCase().contains(type) ||
                    info.activityInfo.name.toLowerCase().contains(type) ) {
                share.setPackage(info.activityInfo.packageName);
                share.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
                found = true;
                break;
            }
        }
        if (!found)
            return;
        context.startActivity(Intent.createChooser(share, "分享到"));
    }
}
 
Example 7
Project: RoadLab-Pro   File: EMailUtil.java   View Source Code Vote up 7 votes
public static void sendAttachFileMail(Context c, String[] path,
		String subject, String type) {
	final Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
	emailIntent.setType(type);
	emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
	emailIntent.putExtra(Intent.EXTRA_TEXT, subject);
       ArrayList<Uri> uris = new ArrayList<Uri>();

       for (String file : path) {
           File fileIn = new File(file);
           Uri u = Uri.fromFile(fileIn);
           uris.add(u);
       }
       emailIntent.putExtra(Intent.EXTRA_STREAM, uris);
       try {
           c.startActivity(Intent.createChooser(emailIntent, subject));
       } catch (Exception e) {
           Log.e(TAG, "sendAttachFileMail", e);
       }
}
 
Example 8
Project: FloatingNew   File: FeedbackActivity.java   View Source Code Vote up 7 votes
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 = Uri.parse("file://" + realPath);
            uris.add(uri);
        }
        emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        startActivity(Utils.createEmailOnlyChooserIntent(this, emailIntent, getString(R.string.send_feedback_two)));
    }
 
Example 9
Project: fitnotifications   File: DebugLog.java   View Source Code Vote up 6 votes
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;
}
 
Example 10
Project: tubik   File: SendLog.java   View Source Code Vote up 6 votes
private void sendLogFile () {
    Intent intent = new Intent (Intent.ACTION_SEND_MULTIPLE);
    intent.setType("plain/text");

    ArrayList<Uri> attachList = new ArrayList<>();
    if (new File(mLogcatFile).exists())
        attachList.add(Uri.parse ("file://" + mLogcatFile));

    intent.putExtra (Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
    intent.putExtra (Intent.EXTRA_SUBJECT, "Disney Radio crash report " + getCurrentTimeStamp());
    intent.putParcelableArrayListExtra (Intent.EXTRA_STREAM, attachList);
    intent.putExtra (Intent.EXTRA_TEXT, "Log file attached."); // do this so some email clients don't complain about empty body.
    startActivity(intent);
}