Example usage for android.content Intent ACTION_SEND_MULTIPLE

List of usage examples for android.content Intent ACTION_SEND_MULTIPLE

Introduction

In this page you can find the example usage for android.content Intent ACTION_SEND_MULTIPLE.

Prototype

String ACTION_SEND_MULTIPLE

To view the source code for android.content Intent ACTION_SEND_MULTIPLE.

Click Source Link

Document

Activity Action: Deliver multiple data to someone else.

Usage

From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java

public void processIntent(Intent intent) {
    String action = intent.getAction();

    if (SafeSlingerConfig.Intent.ACTION_MESSAGEINCOMING.equals(action)) {
        // clicked on new message notifications window, show messages
        // collapse messages to threads when looking for new messages
        MessagesFragment.setRecip(null);
        setTab(Tabs.MESSAGE);/*from  w  ww.ja  va 2s . c om*/
        refreshView();

    } else if (SafeSlingerConfig.Intent.ACTION_BACKUPNOTIFY.equals(action)) {
        // clicked on backup reminder notifications window, show reminder
        // query
        showBackupQuery();
        refreshView();

    } else if (SafeSlingerConfig.Intent.ACTION_SLINGKEYSNOTIFY.equals(action)) {
        // clicked on exchange reminder, show exchange tab
        setTab(Tabs.SLINGKEYS);
        refreshView();

    } else if (SafeSlingerConfig.Intent.ACTION_CHANGESETTINGS.equals(action)) {

        // clicked on pass cache notification
        showSettings();
        refreshView();

    } else if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
        // clicked share externally, load file, show compose
        if (handleSendToAction()) {
            setTab(Tabs.COMPOSE);
        }
    } else {
        setProperDefaultTab();
    }
}

From source file:cn.ucai.wechat.ui.SettingsActivity.java

void sendLogThroughMail() {
    String logPath = "";
    try {/*  www  . j  ava  2s .  com*/
        logPath = EMClient.getInstance().compressLogs();
    } catch (Exception e) {
        e.printStackTrace();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(SettingsActivity.this, "compress logs failed", Toast.LENGTH_LONG).show();
            }
        });
        return;
    }
    File f = new File(logPath);
    File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    if (f.exists() && f.canRead()) {
        try {
            storage.mkdirs();
            File temp = File.createTempFile("hyphenate", ".log.gz", storage);
            if (!temp.canWrite()) {
                return;
            }
            boolean result = f.renameTo(temp);
            if (result == false) {
                return;
            }
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            intent.setData(Uri.parse("mailto:"));
            intent.putExtra(Intent.EXTRA_SUBJECT, "log");
            intent.putExtra(Intent.EXTRA_TEXT, "log in attachment: " + temp.getAbsolutePath());

            intent.setType("application/octet-stream");
            ArrayList<Uri> uris = new ArrayList<>();
            uris.add(Uri.fromFile(temp));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            startActivity(intent);
        } catch (final Exception e) {
            e.printStackTrace();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(SettingsActivity.this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                }
            });
        }
    }
}

From source file:com.owncloud.android.ui.activity.ReceiveExternalFilesActivity.java

private void prepareStreamsToUpload() {
    if (getIntent().getAction().equals(Intent.ACTION_SEND)) {
        mStreamsToUpload = new ArrayList<>();
        mStreamsToUpload.add(getIntent().getParcelableExtra(Intent.EXTRA_STREAM));
        if (mStreamsToUpload.get(0) != null) {
            String streamToUpload = mStreamsToUpload.get(0).toString();
            if (streamToUpload.contains("/data") && streamToUpload.contains(getPackageName())
                    && !streamToUpload.contains(getCacheDir().getPath())) {
                finish();/*www  .  j av a2s.c om*/
            }
        }
    } else if (getIntent().getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
        mStreamsToUpload = getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);
    }
}

From source file:com.dwdesign.tweetings.activity.ComposeActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    mService = getTweetingsApplication().getServiceInterface();
    mResolver = getContentResolver();//  w  w  w  . j  a v  a  2s . c  o m
    super.onCreate(savedInstanceState);
    setContentView(R.layout.compose);
    mActionBar = getSupportActionBar();
    mActionBar.setDisplayHomeAsUpEnabled(true);

    mUploadProvider = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null);

    final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
    final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1;
    mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null;
    mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1;
    mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null;
    mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null;
    mInReplyToText = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_TWEET) : null;
    mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false;
    mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false;
    mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null;
    final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null;
    final String account_username = getAccountUsername(this, account_id);
    int text_selection_start = -1;
    mIsBuffer = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_BUFFER, false) : false;

    if (mInReplyToStatusId > 0) {
        if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null
                && (mentions == null || mentions.length < 1)) {
            mText = bundle.getString(INTENT_KEY_TEXT);
        } else if (mentions != null) {
            final StringBuilder builder = new StringBuilder();
            for (final String mention : mentions) {
                if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) {
                    builder.append('@' + account_username + ' ');
                } else if (!mention.equalsIgnoreCase(account_username)) {
                    builder.append('@' + mention + ' ');
                }
            }
            mText = builder.toString();
            text_selection_start = mText.indexOf(' ') + 1;
        }

        mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false;

        final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false);
        final String name = display_name ? mInReplyToName : mInReplyToScreenName;
        if (name != null) {
            setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to, name));
        }
        if (mAccountIds == null || mAccountIds.length == 0) {
            mAccountIds = new long[] { account_id };
        }
        TextView replyText = (TextView) findViewById(R.id.reply_text);
        if (!isNullOrEmpty(mInReplyToText)) {
            replyText.setVisibility(View.VISIBLE);
            replyText.setText(mInReplyToText);
        } else {
            replyText.setVisibility(View.GONE);
        }
    } else {
        if (mentions != null) {
            final StringBuilder builder = new StringBuilder();
            for (final String mention : mentions) {
                if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_username)) {
                    builder.append('@' + account_username + ' ');
                } else if (!mention.equalsIgnoreCase(account_username)) {
                    builder.append('@' + mention + ' ');
                }
            }
            mText = builder.toString();
        }
        if (mAccountIds == null || mAccountIds.length == 0) {
            final long[] ids_in_prefs = ArrayUtils
                    .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ',');
            final long[] activated_ids = getActivatedAccountIds(this);
            final long[] intersection = ArrayUtils.intersection(ids_in_prefs, activated_ids);
            mAccountIds = intersection.length > 0 ? intersection : activated_ids;
        }
        final String action = getIntent().getAction();
        if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
            setTitle(R.string.share);
            final Bundle extras = getIntent().getExtras();
            if (extras != null) {
                if (mText == null) {
                    final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT);
                    final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT);
                    mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text));
                } else {
                    mText = bundle.getString(INTENT_KEY_TEXT);
                }
                if (mImageUri == null) {
                    final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM);
                    final String content_type = getIntent().getType();
                    if (extra_stream != null && content_type != null && content_type.startsWith("image/")) {
                        final String real_path = getImagePathFromUri(this, extra_stream);
                        final File file = real_path != null ? new File(real_path) : null;
                        if (file != null && file.exists()) {
                            mImageUri = Uri.fromFile(file);
                            mIsImageAttached = true;
                            mIsPhotoAttached = false;
                        } else {
                            mImageUri = null;
                            mIsImageAttached = false;
                        }
                    }
                }
            }
        } else if (bundle != null) {

            if (bundle.getString(INTENT_KEY_TEXT) != null) {
                mText = bundle.getString(INTENT_KEY_TEXT);
            }
        }
    }

    final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme())
            ? new File(mImageUri.getPath())
            : null;
    final boolean image_file_valid = image_file != null && image_file.exists();
    mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE);
    if (image_file_valid) {
        reloadAttachedImageThumbnail(image_file);
    }

    mImageThumbnailPreview.setOnClickListener(this);
    mImageThumbnailPreview.setOnLongClickListener(this);
    mMenuBar.setOnMenuItemClickListener(this);
    mMenuBar.inflate(R.menu.menu_compose);
    mMenuBar.show();
    if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) {
        mEditText.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
        mEditText.setMovementMethod(ArrowKeyMovementMethod.getInstance());
        mEditText.setImeOptions(EditorInfo.IME_ACTION_GO);
        mEditText.setOnEditorActionListener(this);
    }
    mEditText.addTextChangedListener(this);
    if (mText != null) {
        mEditText.setText(mText);
        if (mIsQuote) {
            mEditText.setSelection(0);
        } else if (text_selection_start != -1 && text_selection_start < mEditText.length()
                && mEditText.length() > 0) {
            mEditText.setSelection(text_selection_start, mEditText.length() - 1);
        } else if (mEditText.length() > 0) {
            mEditText.setSelection(mEditText.length());
        }
    }
    invalidateSupportOptionsMenu();
    setMenu();
    if (mColorIndicator != null) {
        mColorIndicator.setOrientation(ColorView.VERTICAL);
        mColorIndicator.setColor(getAccountColors(this, mAccountIds));
    }
    mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED)
            : false;
    mIsPossiblySensitive = savedInstanceState != null
            ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE)
            : false;
}

From source file:com.kevin.cattalk.ui.SettingsFragment.java

void sendLogThroughMail() {
    String logPath = "";
    try {//from   ww w.j a  v a  2s .c  o  m
        logPath = EMClient.getInstance().compressLogs();
    } catch (Exception e) {
        e.printStackTrace();
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(getActivity(), "compress logs failed", Toast.LENGTH_LONG).show();
            }
        });
        return;
    }
    File f = new File(logPath);
    File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    if (f.exists() && f.canRead()) {
        try {
            storage.mkdirs();
            File temp = File.createTempFile("hyphenate", ".log.gz", storage);
            if (!temp.canWrite()) {
                return;
            }
            boolean result = f.renameTo(temp);
            if (result == false) {
                return;
            }
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            intent.setData(Uri.parse("mailto:"));
            intent.putExtra(Intent.EXTRA_SUBJECT, "log");
            intent.putExtra(Intent.EXTRA_TEXT, "log in attachment: " + temp.getAbsolutePath());

            intent.setType("application/octet-stream");
            ArrayList<Uri> uris = new ArrayList<>();
            uris.add(Uri.fromFile(temp));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            startActivity(intent);
        } catch (final Exception e) {
            e.printStackTrace();
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(getContext(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                }
            });
        }
    }
}

From source file:com.github.dfa.diaspora_android.activity.MainActivity.java

/**
 * Handle intents and execute intent specific actions
 *
 * @param intent intent to get handled/*from w ww.ja va2  s  .com*/
 */
private void handleIntent(Intent intent) {
    AppLog.i(this, "handleIntent()");
    if (intent == null) {
        AppLog.v(this, "Intent was null");
        return;
    }

    String action = intent.getAction();
    String type = intent.getType();
    String loadUrl = null;
    AppLog.v(this, "Action: " + action + " Type: " + type);
    if (Intent.ACTION_MAIN.equals(action)) {
        loadUrl = urls.getStreamUrl();
    } else if (ACTION_OPEN_URL.equals(action)) {
        loadUrl = intent.getStringExtra(URL_MESSAGE);
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getDataString() != null) {
        Uri data = intent.getData();
        if (data != null && data.toString().startsWith(CONTENT_HASHTAG)) {
            handleHashtag(intent);
            return;
        } else {
            loadUrl = intent.getDataString();
            AppLog.v(this, "Intent has a delicious URL for us: " + loadUrl);
        }
    } else if (ACTION_CHANGE_ACCOUNT.equals(action)) {
        AppLog.v(this, "Reset pod data and  show PodSelectionFragment");
        appSettings.setPod(null);
        runOnUiThread(new Runnable() {
            public void run() {
                navheaderTitle.setText(R.string.app_name);
                navheaderDescription.setText(R.string.app_subtitle);
                navheaderImage.setImageResource(R.drawable.ic_launcher);
                app.resetPodData(
                        ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG)).getWebView());
            }
        });
        showFragment(getFragment(PodSelectionFragment.TAG));
    } else if (ACTION_CLEAR_CACHE.equals(action)) {
        AppLog.v(this, "Clear WebView cache");
        runOnUiThread(new Runnable() {
            public void run() {
                ContextMenuWebView wv = ((DiasporaStreamFragment) getFragment(DiasporaStreamFragment.TAG))
                        .getWebView();
                if (wv != null) {
                    wv.clearCache(true);
                }
            }
        });

    } else if (Intent.ACTION_SEND.equals(action) && type != null) {
        switch (type) {
        case "text/plain":
            if (intent.hasExtra(Intent.EXTRA_SUBJECT)) {
                handleSendSubject(intent);
            } else {
                handleSendText(intent);
            }
            break;
        case "image/*":
            handleSendImage(intent); //TODO: Add intent filter to Manifest and implement method
            break;
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {
        /* TODO: Implement and add filter to manifest */
        return;
    }
    //Catch split screen recreation
    if (action != null && action.equals(Intent.ACTION_MAIN) && getTopFragment() != null) {
        return;
    }

    if (loadUrl != null) {
        navDrawer.closeDrawers();
        openDiasporaUrl(loadUrl);
    }
}

From source file:com.sweetiepiggy.raspberrybusmalaysia.SubmitTripActivity.java

private void send_email(String msg) {
    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { EMAIL_ADDRESS });
    intent.putExtra(Intent.EXTRA_SUBJECT, EMAIL_SUBJECT);
    intent.putExtra(Intent.EXTRA_TEXT, msg);
    intent.setType("text/plain");
    startActivity(Intent.createChooser(intent, getResources().getString(R.string.send_email)));
}

From source file:com.mbientlab.metawear.app.LoggingFragment.java

private void startEmailIntent() {
    mwMnger.getCurrentController().removeModuleCallback(sensors[sensorIndex]);

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

    try {//w  w  w .  j a  va  2 s  .c om
        for (File it : sensors[sensorIndex].saveDataToFile()) {
            fileUris.add(
                    FileProvider.getUriForFile(getActivity(), "com.mbientlab.metawear.app.fileprovider", it));
        }

        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT,
                String.format(Locale.US, "Logged %s data - %tY-%<tm-%<tdT%<tH-%<tM-%<tS",
                        sensors[sensorIndex].toString(), Calendar.getInstance().getTime()));

        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUris);
        startActivity(Intent.createChooser(intent, "Send email..."));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:eu.basicairdata.graziano.gpslogger.FragmentTracklist.java

@Subscribe
public void onEvent(EventBusMSGNormal msg) {
    if (msg.MSGType == EventBusMSG.TRACKLIST_SELECTION) {
        final long selID = msg.id;
        if (selID >= 0) {
            getActivity().runOnUiThread(new Runnable() {
                @Override//w  ww.  j a  v a  2s.co  m
                public void run() {
                    selectedtrackID = selID;
                    registerForContextMenu(view);
                    getActivity().openContextMenu(view);
                    unregisterForContextMenu(view);
                }
            });
        }
    }
    if (msg.MSGType == EventBusMSG.INTENT_SEND) {
        final long trackid = msg.id;
        if (trackid > 0) {
            Track track = GPSApplication.getInstance().GPSDataBase.getTrack(trackid);

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_SEND_MULTIPLE);
            //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(Intent.EXTRA_SUBJECT, "GPS Logger - Track " + track.getName());

            PhysicalDataFormatter phdformatter = new PhysicalDataFormatter();
            PhysicalData phdDuration;
            PhysicalData phdSpeedMax;
            PhysicalData phdSpeedAvg;
            PhysicalData phdDistance;
            PhysicalData phdAltitudeGap;
            PhysicalData phdOverallDirection;
            phdDuration = phdformatter.format(track.getPrefTime(), PhysicalDataFormatter.FORMAT_DURATION);
            phdSpeedMax = phdformatter.format(track.getSpeedMax(), PhysicalDataFormatter.FORMAT_SPEED);
            phdSpeedAvg = phdformatter.format(track.getPrefSpeedAverage(),
                    PhysicalDataFormatter.FORMAT_SPEED_AVG);
            phdDistance = phdformatter.format(track.getEstimatedDistance(),
                    PhysicalDataFormatter.FORMAT_DISTANCE);
            phdAltitudeGap = phdformatter.format(
                    track.getEstimatedAltitudeGap(
                            GPSApplication.getInstance().getPrefEGM96AltitudeCorrection()),
                    PhysicalDataFormatter.FORMAT_ALTITUDE);
            phdOverallDirection = phdformatter.format(track.getBearing(), PhysicalDataFormatter.FORMAT_BEARING);
            if (track.getNumberOfLocations() <= 1) {
                intent.putExtra(Intent.EXTRA_TEXT,
                        (CharSequence) ("GPS Logger - Track " + track.getName() + "\n"
                                + track.getNumberOfLocations() + " " + getString(R.string.trackpoints) + "\n"
                                + track.getNumberOfPlacemarks() + " " + getString(R.string.placemarks)));
            } else {
                intent.putExtra(Intent.EXTRA_TEXT,
                        (CharSequence) ("GPS Logger - Track " + track.getName() + "\n"
                                + track.getNumberOfLocations() + " " + getString(R.string.trackpoints) + "\n"
                                + track.getNumberOfPlacemarks() + " " + getString(R.string.placemarks) + "\n"
                                + "\n" + getString(R.string.pref_track_stats) + " "
                                + (GPSApplication.getInstance().getPrefShowTrackStatsType() == 0
                                        ? getString(R.string.pref_track_stats_totaltime)
                                        : getString(R.string.pref_track_stats_movingtime))
                                + ":" + "\n" + getString(R.string.distance) + " = " + phdDistance.Value + " "
                                + phdDistance.UM + "\n" + getString(R.string.duration) + " = "
                                + phdDuration.Value + "\n" + getString(R.string.altitude_gap) + " = "
                                + phdAltitudeGap.Value + " " + phdAltitudeGap.UM + "\n"
                                + getString(R.string.max_speed) + " = " + phdSpeedMax.Value + " "
                                + phdSpeedMax.UM + "\n" + getString(R.string.average_speed) + " = "
                                + phdSpeedAvg.Value + " " + phdSpeedAvg.UM + "\n"
                                + getString(R.string.overall_direction) + " = " + phdOverallDirection.Value
                                + " " + phdOverallDirection.UM));
            }
            intent.setType("text/xml");

            ArrayList<Uri> files = new ArrayList<>();
            String fname = track.getName() + ".kml";
            File file = new File(Environment.getExternalStorageDirectory() + "/GPSLogger/AppData/", fname);
            if (file.exists() && GPSApplication.getInstance().getPrefExportKML()) {
                Uri uri = Uri.fromFile(file);
                files.add(uri);
            }
            fname = track.getName() + ".gpx";
            file = new File(Environment.getExternalStorageDirectory() + "/GPSLogger/AppData/", fname);
            if (file.exists() && GPSApplication.getInstance().getPrefExportGPX()) {
                Uri uri = Uri.fromFile(file);
                files.add(uri);
            }
            fname = track.getName() + ".txt";
            file = new File(Environment.getExternalStorageDirectory() + "/GPSLogger/AppData/", fname);
            if (file.exists() && GPSApplication.getInstance().getPrefExportTXT()) {
                Uri uri = Uri.fromFile(file);
                files.add(uri);
            }

            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);

            String title = getString(R.string.card_menu_share);
            // Create intent to show chooser
            Intent chooser = Intent.createChooser(intent, title);

            // Verify the intent will resolve to at least one activity
            if ((intent.resolveActivity(getContext().getPackageManager()) != null) && (!files.isEmpty())) {
                startActivity(chooser);
            }
        }
    }
}

From source file:com.visva.voicerecorder.utils.Utils.java

public static void shareMultiFileByShareActionMode(Context context, ArrayList<RecordingSession> selectedList) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND_MULTIPLE);
    intent.putExtra(Intent.EXTRA_SUBJECT, "Here are some files.");
    intent.setType("image/jpeg"); /* This example is sharing jpeg images. */

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

    for (RecordingSession recordingSession : selectedList /* List of the files you want to send */) {
        File file = new File(recordingSession.fileName);
        Uri uri = Uri.fromFile(file);//from w w  w  .ja v a  2s  .c  o  m
        files.add(uri);
    }

    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
    context.startActivity(intent);
}