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:com.groksolutions.grok.mobile.GrokActivity.java

/**
 * Send user feedback via email with pre-populated email address, screen capture and optional
 * upload identifier/*from   w w  w  . j  a  va  2 s  .  c o  m*/
 * <p/>
 *
 * @param uploadId the identifier of the uploaded information; null if none
 */
protected void emailFeedback(final CharSequence uploadId) {
    Intent feedbackIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    feedbackIntent.putExtra(Intent.EXTRA_EMAIL,
            new String[] { getResources().getText(R.string.feedback_email_address).toString() });
    String subject = getResources().getText(R.string.feedback_email_subject).toString();

    feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    feedbackIntent.setType("message/rfc822");
    ArrayList<Uri> uris = new ArrayList<Uri>();
    uris.add(takeScreenCapture(true));
    if (uploadId != null) {
        uris.add(writeTextFileToSend(uploadId.toString()));
    }
    feedbackIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

    startActivity(Intent.createChooser(feedbackIntent, getResources().getText(R.string.title_feedback)));
}

From source file:org.totschnig.myexpenses.util.Utils.java

public static void share(Context ctx, ArrayList<File> files, String target, String mimeType) {
    URI uri = null;/*from  ww  w .j a v a  2  s.  c  o m*/
    Intent intent;
    String scheme = "mailto";
    boolean multiple = files.size() > 1;
    if (!target.equals("")) {
        uri = Utils.validateUri(target);
        if (uri == null) {
            Toast.makeText(ctx, ctx.getString(R.string.ftp_uri_malformed, target), Toast.LENGTH_LONG).show();
            return;
        }
        scheme = uri.getScheme();
    }
    //if we get a String that does not include a scheme, we interpret it as a mail address
    if (scheme == null) {
        scheme = "mailto";
    }
    if (scheme.equals("ftp")) {
        if (multiple) {
            Toast.makeText(ctx, "sending multiple file through ftp is not supported", Toast.LENGTH_LONG).show();
            return;
        }
        intent = new Intent(android.content.Intent.ACTION_SENDTO);
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(files.get(0)));
        intent.setDataAndType(android.net.Uri.parse(target), mimeType);
        if (!isIntentAvailable(ctx, intent)) {
            Toast.makeText(ctx, R.string.no_app_handling_ftp_available, Toast.LENGTH_LONG).show();
            return;
        }
        ctx.startActivity(intent);
    } else if (scheme.equals("mailto")) {
        if (multiple) {
            intent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
            ArrayList<Uri> uris = new ArrayList<Uri>();
            for (File file : files) {
                uris.add(Uri.fromFile(file));
            }
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        } else {
            intent = new Intent(android.content.Intent.ACTION_SEND);
            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(files.get(0)));
        }
        intent.setType(mimeType);
        if (uri != null) {
            String address = uri.getSchemeSpecificPart();
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
        }
        intent.putExtra(Intent.EXTRA_SUBJECT, R.string.export_expenses);
        if (!isIntentAvailable(ctx, intent)) {
            Toast.makeText(ctx, R.string.no_app_handling_email_available, Toast.LENGTH_LONG).show();
            return;
        }
        //if we got mail address, we launch the default application
        //if we are called without target, we launch the chooser in order to make action more explicit
        if (uri != null) {
            ctx.startActivity(intent);
        } else {
            ctx.startActivity(Intent.createChooser(intent, ctx.getString(R.string.share_sending)));
        }
    } else {
        Toast.makeText(ctx, ctx.getString(R.string.share_scheme_not_supported, scheme), Toast.LENGTH_LONG)
                .show();
        return;
    }
}

From source file:com.diedrico.diedricoapp.PicMenuActivity.java

License:asdf

private ImageButton.OnClickListener confirmClickListener() {
    return new View.OnClickListener() {
        @Override//from  w  w  w  .  j a  v  a2s . co m
        public void onClick(View view) {
            if (analyzerFinished) { //The analysis is ok so we pass to 3D, but before we have to differ from a line or a plane and then locate them
                // in the space with trigonometry

                Log.i("asdf", "1: " + landLine.getLineXA() + " 2: " + landLine.getLineXB());

                ArrayList<PointVector> pointVectors = new ArrayList<>(); //we pass the points to PointVector to know his X, his Y and his Z
                for (int i = 0; i < pointDiedrico.size(); i++) {
                    Vector AB = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                            new PointVector(landLine.getLineXB(), landLine.getLineYB()));
                    Vector AC = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                            new PointVector(pointDiedrico.get(i).getY().getPointX(),
                                    pointDiedrico.get(i).getY().getPointY()));
                    Vector AD = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                            new PointVector(pointDiedrico.get(i).getX().getPointX(),
                                    pointDiedrico.get(i).getX().getPointY()));
                    ScalarProduct scalarProductForX = new ScalarProduct(AB, AD);
                    ScalarProduct scalarProductForY = new ScalarProduct(AB, AC);

                    pointVectors.add(new PointVector((float) (scalarProductForY.getHeight() / AB.getModule()),
                            (float) (scalarProductForX.getHeight() / AB.getModule()),
                            -(float) (scalarProductForY.getLength() / AB.getModule()) + 0.5f));
                }

                ArrayList<LineVector> lineVectors = new ArrayList<>();
                ArrayList<PlaneVector> planeVectors = new ArrayList<>();
                for (int i = 0; i < lineDiedrico.size(); i++) {
                    //We have to differ from a line or a plane, the difference its that plane have one view very next from each other (this is only with crosswide planes but for the moment its OK)
                    if (lineDiedrico.get(i).getX().getLineXA() > lineDiedrico.get(i).getY().getLineXA() - 5
                            && lineDiedrico.get(i).getX().getLineXA() < lineDiedrico.get(i).getY().getLineXA()
                                    + 5
                            && lineDiedrico.get(i).getX().getLineYA() > lineDiedrico.get(i).getY().getLineYA()
                                    - 5
                            && lineDiedrico.get(i).getX().getLineYA() > lineDiedrico.get(i).getY().getLineYA()
                                    + 5) { //It seems to be a plane

                        Vector AB = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(landLine.getLineXB(), landLine.getLineYB()));
                        Vector AC = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getY().getLineXA(),
                                        lineDiedrico.get(i).getY().getLineYA()));
                        Vector AD = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getY().getLineXB(),
                                        lineDiedrico.get(i).getY().getLineYB()));
                        Vector AE = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getX().getLineXA(),
                                        lineDiedrico.get(i).getX().getLineYA()));
                        Vector AF = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getX().getLineXB(),
                                        lineDiedrico.get(i).getX().getLineYB()));

                        ScalarProduct scalarProductBeginningPlane;
                        ScalarProduct scalarProductX;
                        ScalarProduct scalarProductY;

                        if (lineDiedrico.get(i).getY().getLineYA() > lineDiedrico.get(i).getY().getLineYB()) { //Problem with planes
                            scalarProductBeginningPlane = new ScalarProduct(AB, AD);
                            scalarProductX = new ScalarProduct(AB, AE);
                            scalarProductY = new ScalarProduct(AB, AC);
                        } else {
                            scalarProductBeginningPlane = new ScalarProduct(AB, AC);
                            scalarProductX = new ScalarProduct(AB, AF);
                            scalarProductY = new ScalarProduct(AB, AD);
                        }

                        PointVector pointVector1 = new PointVector(0, 0,
                                (float) (scalarProductBeginningPlane.getLength() / AB.getModule()));
                        PointVector pointVector2 = new PointVector(0.0f,
                                (float) (scalarProductY.getHeight() / AB.getModule()),
                                (float) (scalarProductY.getLength() / AB.getModule()));
                        PointVector pointVector3 = new PointVector(
                                (float) (scalarProductX.getHeight() / AB.getModule()), 0.0f,
                                (float) (scalarProductY.getLength() / AB.getModule()));
                        PointVector pointVector4 = pointVector2.getMidPoint(pointVector3);

                        planeVectors
                                .add(new PlaneVector(pointVector1, pointVector2, pointVector3, pointVector4));
                    } else { //It seems to be a line
                        Vector AB = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(landLine.getLineXB(), landLine.getLineYB()));
                        Vector AC = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getX().getLineXA(),
                                        lineDiedrico.get(i).getX().getLineYA()));
                        Vector AD = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getY().getLineXA(),
                                        lineDiedrico.get(i).getY().getLineYA()));
                        Vector AE = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getX().getLineXB(),
                                        lineDiedrico.get(i).getX().getLineYB()));
                        Vector AF = new Vector(new PointVector(landLine.getLineXA(), landLine.getLineYA()),
                                new PointVector(lineDiedrico.get(i).getY().getLineXB(),
                                        lineDiedrico.get(i).getY().getLineYB()));

                        ScalarProduct scalarProductXA = new ScalarProduct(AB, AD);
                        ScalarProduct scalarProductYA = new ScalarProduct(AB, AC);
                        ScalarProduct scalarProductXB = new ScalarProduct(AB, AF);
                        ScalarProduct scalarProductYB = new ScalarProduct(AB, AE);

                        Log.i("asdf",
                                "YA " + (float) (scalarProductYA.getHeight() / AB.getModule()) + " XA "
                                        + (float) (scalarProductXA.getHeight() / AB.getModule()) + " ZA "
                                        + (float) (scalarProductYA.getLength() / AB.getModule()) + " YB "
                                        + (float) (scalarProductYB.getHeight() / AB.getModule()) + " XB "
                                        + (float) (scalarProductXB.getHeight() / AB.getModule()) + " ZB "
                                        + (float) (scalarProductYB.getLength() / AB.getModule()));

                        lineVectors.add(new LineVector((float) (scalarProductYA.getHeight() / AB.getModule()),
                                (float) (scalarProductXA.getHeight() / AB.getModule()),
                                -(float) (scalarProductYA.getLength() / AB.getModule()) + 0.5f,
                                (float) (scalarProductYB.getHeight() / AB.getModule()),
                                (float) (scalarProductXB.getHeight() / AB.getModule()),
                                -(float) (scalarProductYB.getLength() / AB.getModule()) + 0.5f));

                    }
                }

                Intent intent = new Intent(getApplicationContext(), OpenGlActivity.class); //we pass the vector to OpenGL
                intent.putParcelableArrayListExtra("points", pointVectors);
                intent.putParcelableArrayListExtra("lines", lineVectors);
                intent.putParcelableArrayListExtra("planes", planeVectors);

                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                getApplicationContext().startActivity(intent);

                Toast.makeText(context, "aaaaaa", Toast.LENGTH_LONG).show();
            } else { //There is no analysis so we analyse the pic
                Toast.makeText(context, "Analyzing", Toast.LENGTH_LONG).show();
                new PicAnalyzer(10, analyzerFinished()).execute(thresholdingBitmap); //to scan interesting points and interesting lines
            }
        }
    };
}

From source file:com.veniosg.dir.android.fragment.SimpleFileListFragment.java

private boolean handleMultipleSelectionAction(ActionMode mode, MenuItem item) {
    DialogFragment dialog;/*from www.  j a va 2  s.  c om*/
    Bundle args;
    ArrayList<FileHolder> fItems = getCheckedItems();

    switch (item.getItemId()) {
    case R.id.menu_send:
        mode.finish();
        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        ArrayList<Uri> uris = new ArrayList<Uri>();
        intent.setType("text/plain");

        for (FileHolder fh : fItems) {
            if (!fh.getFile().isDirectory())
                uris.add(FileUtils.getUri(fh));
        }

        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

        try {
            startActivity(Intent.createChooser(intent, getString(R.string.send_chooser_title)));
            return true;
        } catch (ActivityNotFoundException e) {
            Toast.makeText(getActivity(), R.string.send_not_available, Toast.LENGTH_SHORT).show();
            return true;
        }
    case R.id.menu_delete:
        mode.finish();
        dialog = new MultiDeleteDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelableArrayList(IntentConstants.EXTRA_DIALOG_FILE_HOLDER,
                new ArrayList<Parcelable>(fItems));
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), MultiDeleteDialog.class.getName());
        return true;
    case R.id.menu_move:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().cut(fItems);
        getActivity().supportInvalidateOptionsMenu();
        return true;
    case R.id.menu_copy:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().copy(fItems);
        getActivity().supportInvalidateOptionsMenu();
        return true;
    case R.id.menu_compress:
        mode.finish();
        dialog = new MultiCompressDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelableArrayList(IntentConstants.EXTRA_DIALOG_FILE_HOLDER,
                new ArrayList<Parcelable>(fItems));
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), MultiCompressDialog.class.getName());
        return true;
    default:
        return false;
    }
}

From source file:com.jecelyin.android.file_explorer.FileExplorerAction.java

private void shareFile() {
    if (checkedList.isEmpty() || shareActionProvider == null)
        return;//from w  w w.  j  a v a2  s .co  m

    Intent shareIntent = new Intent();
    if (checkedList.size() == 1) {
        File localFile = new File(checkedList.get(0).getPath());
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.setType(MimeTypes.getInstance().getMimeType(localFile.getPath()));
        shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(localFile));
    } else {
        shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);

        ArrayList<Uri> streams = new ArrayList<>();
        for (JecFile file : checkedList) {
            if (!(file instanceof LocalFile))
                throw new ExplorerException(
                        context.getString(R.string.can_not_share_x, file + " isn't LocalFile"));

            streams.add(Uri.fromFile(new File(file.getPath())));
        }

        shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, streams);
    }

    shareActionProvider.setShareIntent(shareIntent);
}

From source file:it.geosolutions.android.map.MapsActivity.java

/**
 * add the confirm button to the control bar
 *///from w  w w .  ja v a2 s .  c o m
private void addConfirmButton() {
    Log.v("MapsActivity", "adding confirm button");
    ImageButton b = (ImageButton) findViewById(R.id.button_confirm_marker_position);
    b.setVisibility(View.VISIBLE);
    final MapsActivity activity = this;
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (!canConfirm) {
                Toast.makeText(activity, R.string.error_unable_getfeature_db, Toast.LENGTH_LONG).show();
                return;
            }

            new AlertDialog.Builder(activity).setTitle(R.string.button_confirm_marker_position_title)
                    .setMessage(R.string.button_confirm_marker_position)
                    .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            Intent returnIntent = new Intent();
                            //get current markers
                            ArrayList<DescribedMarker> markers = overlayManager.getMarkerOverlay().getMarkers();
                            //serialize markers in the response
                            returnIntent.putParcelableArrayListExtra(MapsActivity.PARAMETERS.MARKERS,
                                    MarkerUtils.getMarkersDTO(markers));
                            setResult(RESULT_OK, returnIntent);
                            finish();
                            return;
                            //if you don't want to return data:
                            //                    setResult(RESULT_CANCELED, returnIntent);        
                            //                    finish();
                            //                    activity.finish();
                        }

                    }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // do nothing
                        }
                    }).show();

        }
    });
}

From source file:app.hacked.MainActivity.java

@Override
public void onProjectItemSelected(Project project) {
    if (findViewById(R.id.ProjectDetails) != null) {
        mTwoPane = true;/*  w w w .  j av a  2  s.  c o  m*/

        Bundle arguments = new Bundle();
        arguments.putInt(ProjectDetailsFragment.PROJECTID, project.ID);
        arguments.putString(ProjectDetailsFragment.NAME, project.Name);
        arguments.putString(ProjectDetailsFragment.SYNOPSIS, project.Synopsis);
        arguments.putString(ProjectDetailsFragment.DESCRIPTION, project.Description);
        arguments.putString(ProjectDetailsFragment.LOCATION, project.Location);
        arguments.putString(ProjectDetailsFragment.TECHNOLOGIES, project.Technologies);
        arguments.putInt(ProjectDetailsFragment.POPULARITY, project.Popularity);
        //arguments.putString(ProjectDetailsFragment.TEAMMEMBERS, project.getTeamMembers());
        arguments.putBoolean(ProjectDetailsFragment.ARG_2PANE, true);
        arguments.putParcelableArrayList(ProjectDetailsFragment.TEAMMEMBERS, project.TeamMembers);

        ProjectDetailsFragment fragment = new ProjectDetailsFragment();
        fragment.setArguments(arguments);
        fragment.setHasOptionsMenu(true);
        getSupportFragmentManager().beginTransaction().replace(R.id.ProjectDetails, fragment).commit();
    } else {
        mTwoPane = false;

        Intent detailIntent = new Intent(this, ProjectDetailsActivity.class);
        detailIntent.putExtra(ProjectDetailsFragment.PROJECTID, project.ID);
        detailIntent.putExtra(ProjectDetailsFragment.NAME, project.Name);
        detailIntent.putExtra(ProjectDetailsFragment.SYNOPSIS, project.Synopsis);
        detailIntent.putExtra(ProjectDetailsFragment.DESCRIPTION, project.Description);
        detailIntent.putExtra(ProjectDetailsFragment.LOCATION, project.Location);
        detailIntent.putExtra(ProjectDetailsFragment.TECHNOLOGIES, project.Technologies);
        detailIntent.putExtra(ProjectDetailsFragment.POPULARITY, project.Popularity);
        //detailIntent.putExtra(ProjectDetailsFragment.TEAMMEMBERS, project.getTeamMembers());
        detailIntent.putParcelableArrayListExtra(ProjectDetailsFragment.TEAMMEMBERS, project.TeamMembers);
        detailIntent.putExtra(ProjectDetailsFragment.ARG_2PANE, false);
        startActivity(detailIntent);
    }
}

From source file:foam.jellyfish.StarwispBuilder.java

public static void email(Context context, String emailTo, String emailCC, String subject, String emailText,
        List<String> filePaths) {
    //need to "send multiple" to get more than one attachment
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("text/plain");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailTo });
    emailIntent.putExtra(android.content.Intent.EXTRA_CC, new String[] { emailCC });
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

    ArrayList<String> extra_text = new ArrayList<String>();
    extra_text.add(emailText);/*from  w  w w .j a v a  2s  . c  om*/
    emailIntent.putStringArrayListExtra(Intent.EXTRA_TEXT, extra_text);
    //emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);

    //has to be an ArrayList
    ArrayList<Uri> uris = new ArrayList<Uri>();
    //convert from paths to Android friendly Parcelable Uri's
    for (String file : filePaths) {
        File fileIn = new File(file);
        Uri u = Uri.fromFile(fileIn);
        uris.add(u);
    }
    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}

From source file:org.naturenet.ui.MainActivity.java

public void goToAddObservationActivity(boolean fromCamera) {
    Intent addObservation = new Intent(this, AddObservationActivity.class);
    addObservation.putParcelableArrayListExtra(AddObservationActivity.EXTRA_IMAGE_PATH, selectedImages);
    addObservation.putExtra("fromCamera", fromCamera);
    addObservation.putExtra(AddObservationActivity.EXTRA_LATITUDE, latValue);
    addObservation.putExtra(AddObservationActivity.EXTRA_LONGITUDE, longValue);
    addObservation.putExtra(AddObservationActivity.EXTRA_USER, signed_user);
    startActivity(addObservation);/* ww w  .  j  a v  a2  s .  c o  m*/
    overridePendingTransition(R.anim.slide_up, R.anim.stay);
}