Example usage for android.content Intent putParcelableArrayListExtra

List of usage examples for android.content Intent putParcelableArrayListExtra

Introduction

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

Prototype

public @NonNull Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) 

Source Link

Document

Add extended data to the intent.

Usage

From source file:net.sourceforge.servestream.activity.MainActivity.java

@Override
public void startActivity(Intent intent) {
    // check if search intent
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        Fragment fragment = getSupportFragmentManager().findFragmentByTag(mTag);
        if (fragment != null && fragment instanceof BrowseFragment) {
            intent.putParcelableArrayListExtra("uris", ((BrowseFragment) fragment).getUris());
        }//from w  ww .  j a va 2s.  c  o m
    }

    super.startActivity(intent);
}

From source file:org.gnucash.android.export.ExportAsyncTask.java

/**
 * Starts an intent chooser to allow the user to select an activity to receive
 * the exported files.// w w w .j  a  va  2s.  c  o m
 * @param paths list of full paths of the files to send to the activity.
 */
private void shareFiles(List<String> paths) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    shareIntent.setType("text/xml");

    ArrayList<Uri> exportFiles = convertFilePathsToUris(paths);
    shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, exportFiles);
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    shareIntent.putExtra(Intent.EXTRA_SUBJECT,
            mContext.getString(R.string.title_export_email, mExportParams.getExportFormat().name()));

    String defaultEmail = PreferenceManager.getDefaultSharedPreferences(mContext)
            .getString(mContext.getString(R.string.key_default_export_email), null);
    if (defaultEmail != null && defaultEmail.trim().length() > 0)
        shareIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { defaultEmail });

    SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateTimeInstance();
    ArrayList<CharSequence> extraText = new ArrayList<>();
    extraText.add(mContext.getString(R.string.description_export_email) + " "
            + formatter.format(new Date(System.currentTimeMillis())));
    shareIntent.putExtra(Intent.EXTRA_TEXT, extraText);

    if (mContext instanceof Activity) {
        List<ResolveInfo> activities = mContext.getPackageManager().queryIntentActivities(shareIntent, 0);
        if (activities != null && !activities.isEmpty()) {
            mContext.startActivity(Intent.createChooser(shareIntent,
                    mContext.getString(R.string.title_select_export_destination)));
        } else {
            Toast.makeText(mContext, R.string.toast_no_compatible_apps_to_receive_export, Toast.LENGTH_LONG)
                    .show();
        }
    }
}

From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileActions.java

private void send(Fragment fragment, List<File> selectedFiles) {
    Intent pickResult = new Intent();
    if (selectedFiles.size() == 0) {
        pickResult.setData(Uri.fromFile(selectedFiles.get(0)));
    } else if (selectedFiles.size() > 0) {
        ArrayList<Uri> uris = new ArrayList<Uri>();
        for (File file : selectedFiles) {
            Uri u = Uri.fromFile(file);/*from   w  w w .j  a va 2s .  c o  m*/
            uris.add(u);
        }
        pickResult.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    }
    fragment.getActivity().setResult(FragmentActivity.RESULT_OK, pickResult);
    fragment.getActivity().finish();

}

From source file:link.kjr.file_manager.MainActivity.java

public void send(MenuItem item) {
    ArrayList<Uri> files = new ArrayList<>();
    for (String file : selectedFiles) {

        files.add(Uri.fromFile(new File(file)));
    }//from ww  w  . j  a v a 2s.c om
    Intent share = new Intent();
    share.setAction(Intent.ACTION_SEND_MULTIPLE);
    share.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
    share.setType("*/*");
    startActivity(Intent.createChooser(share, getString(R.string.send_files)));
}

From source file:com.launcher.silverfish.HomeScreenFragment.java

private void addEmptyData(Intent pickIntent) {
    // This is needed work around some weird bug.
    // This will simply add some empty data to the intent.
    ArrayList customInfo = new ArrayList();
    pickIntent.putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, customInfo);
    ArrayList customExtras = new ArrayList();
    pickIntent.putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_EXTRAS, customExtras);
}

From source file:de.schildbach.wallet.ui.ReportIssueDialogBuilder.java

private void startSend(final CharSequence subject, final CharSequence text, final ArrayList<Uri> attachments) {
    final Intent intent;

    if (attachments.size() == 0) {
        intent = new Intent(Intent.ACTION_SEND);
        intent.setType("message/rfc822");
    } else if (attachments.size() == 1) {
        intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_STREAM, attachments.get(0));
    } else {/*  w  ww . j  a v  a2  s .  c o m*/
        intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.setType("text/plain");
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachments);
    }

    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.REPORT_EMAIL });
    if (subject != null)
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);

    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    try {
        context.startActivity(Intent.createChooser(intent,
                context.getString(R.string.report_issue_dialog_mail_intent_chooser)));
        log.info("invoked chooser for sending issue report");
    } catch (final Exception x) {
        Toast.makeText(context, R.string.report_issue_dialog_mail_intent_failed, Toast.LENGTH_LONG).show();
        log.error("report issue failed", x);
    }
}

From source file:com.filepager.afilechooser.FileChooserActivity.java

/**
 * Finish this Activity with a result code and URI of the selected file.
 *
 * @param file The file selected./*from  w  ww.  j  a v a2s .  c  o  m*/
 * @param fh 
 */
private void finishWithResult(File file, FilesHolder fh) {
    if (file != null) {
        Uri uri = Uri.fromFile(file);
        Intent i = new Intent();
        if (fh != null) {
            if (fh.holder.size() > 0) {
                i.putExtra(IntentConstants.IS_MULTIPLE, true);
            } else {
                i.putExtra(IntentConstants.IS_MULTIPLE, false);
            }
        }

        i.putExtra("path", file.getAbsolutePath());
        i.setData(uri);
        if (fh != null)
            i.putParcelableArrayListExtra("files", fh.holder);
        setResult(RESULT_OK, i);
        finish();
    } else {
        setResult(RESULT_CANCELED);
        finish();
    }
}

From source file:com.albedinsky.android.support.intent.ShareIntent.java

/**
 *//*w w w .  j a  v a2 s  .c om*/
@NonNull
@Override
protected Intent onBuild() {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(mDataType);
    if (!TextUtils.isEmpty(mTitle)) {
        intent.putExtra(Intent.EXTRA_TITLE, mTitle);
    }
    if (!TextUtils.isEmpty(mContent)) {
        intent.putExtra(Intent.EXTRA_TEXT, mContent);
    }
    if (mUri != null) {
        intent.putExtra(Intent.EXTRA_STREAM, mUri);
    } else if (mUris != null) {
        intent.setAction(Intent.ACTION_SEND_MULTIPLE);
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(mUris));
    }
    return intent;
}

From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java

/**
 * Setter for the attachments.//  w  ww. j  a v a  2 s  .co m
 *
 * @param attachments
 * List of URIs to attach.
 * @param draft
 * The intent to send.
 * @param ctx
 * The application context.
 * @throws JSONException
 */
private void setAttachments(JSONArray attachments, Intent draft, Context ctx) throws JSONException {

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

    for (int i = 0; i < attachments.length(); i++) {
        Uri uri = getUriForPath(attachments.getString(i), ctx);

        uris.add(uri);
    }

    draft.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
}

From source file:link.kjr.file_manager.MainActivity.java

public void sendSingleFile(String path) {

    Intent i = new Intent();
    ArrayList<Uri> files = new ArrayList<>();
    files.add(Uri.fromFile(new File(path)));
    i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
    i.setType("*/*");
    i.setAction(Intent.ACTION_SEND_MULTIPLE);
    startActivity(Intent.createChooser(i, getString(R.string.send_file)));

}