Example usage for android.content Intent EXTRA_EMAIL

List of usage examples for android.content Intent EXTRA_EMAIL

Introduction

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

Prototype

String EXTRA_EMAIL

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

Click Source Link

Document

A String[] holding e-mail addresses that should be delivered to.

Usage

From source file:us.theparamountgroup.android.inventory.EditorActivity.java

public void orderProduct(View view) {

    String nameProduct = mNameEditText.getText().toString();

    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:")); // only email apps should handle this
    intent.putExtra(Intent.EXTRA_EMAIL, "supplier@example.com");
    intent.putExtra(Intent.EXTRA_SUBJECT, "Order " + nameProduct);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);//  w  ww  .  j av a  2s .c  om
    } else {
        Toast.makeText(this, "Sorry no access to email", Toast.LENGTH_SHORT).show();
        return;
    }

}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Opens a "Contact Us" email, based on the currently selected region
 *
 * @param googleApiClient The GoogleApiClient being used to obtain fused provider updates, or
 *                        null if one isn't available
 *///from  www.ja  v a  2s. co  m
public static void sendContactEmail(Context c, GoogleApiClient googleApiClient) {
    PackageManager pm = c.getPackageManager();
    PackageInfo appInfo;
    try {
        appInfo = pm.getPackageInfo(c.getPackageName(), PackageManager.GET_META_DATA);
    } catch (PackageManager.NameNotFoundException e) {
        // Do nothing, perhaps we'll get to show it again? Or never.
        return;
    }
    ObaRegion region = Application.get().getCurrentRegion();
    if (region == null) {
        return;
    }

    Location loc = Application.getLastKnownLocation(c, googleApiClient);

    // appInfo.versionName
    // Build.MODEL
    // Build.VERSION.RELEASE
    // Build.VERSION.SDK
    // %s\nModel: %s\nOS Version: %s\nSDK Version: %s\
    final String body = c.getString(R.string.bug_report_body, appInfo.versionName, Build.MODEL,
            Build.VERSION.RELEASE, Build.VERSION.SDK_INT, LocationUtils.printLocationDetails(loc));
    Intent send = new Intent(Intent.ACTION_SEND);
    send.putExtra(Intent.EXTRA_EMAIL, new String[] { region.getContactEmail() });
    send.putExtra(Intent.EXTRA_SUBJECT, c.getString(R.string.bug_report_subject));
    send.putExtra(Intent.EXTRA_TEXT, body);
    send.setType("message/rfc822");
    try {
        c.startActivity(Intent.createChooser(send, c.getString(R.string.bug_report_subject)));
    } catch (ActivityNotFoundException e) {
        Toast.makeText(c, R.string.bug_report_error, Toast.LENGTH_LONG).show();
    }
}

From source file:com.apps.gator.DisplayTranslationActivity.java

/**
 * Sends an email with a subject of Feedback.
 *//*from   w  w  w  .j  ava2 s .co m*/
private void openFeedback() {
    final Intent email = new Intent(Intent.ACTION_SEND);
    email.setType("text/email");
    email.putExtra(Intent.EXTRA_EMAIL, new String[] { "sudhirayrota@gmail.com" });
    email.putExtra(Intent.EXTRA_SUBJECT, "Feedback:Gator Translator:");
    email.putExtra(Intent.EXTRA_TEXT, "Dear Gator-Translator Development Team," + "");
    startActivity(Intent.createChooser(email, "Send Feedback:"));

}

From source file:com.apps.gator.DisplayTranslationActivity.java

/**
 * Sends an email with a subject of Report Error.
 *///from ww w. j av  a2s.  c  o  m
private void openReportError() {
    final Intent email = new Intent(Intent.ACTION_SEND);
    email.setType("text/email");
    email.putExtra(Intent.EXTRA_EMAIL, new String[] { "sudhirayrota@gmail.com" });
    email.putExtra(Intent.EXTRA_SUBJECT, "Report Error:Gator Translator:");
    email.putExtra(Intent.EXTRA_TEXT, "Dear Gator-Translator Development Team," + "");
    startActivity(Intent.createChooser(email, "Report Error:"));
}

From source file:com.terraremote.terrafieldreport.OpenGroundReport.java

public void submitDailyGroundTailgate() {

    gatherValues();/*www.j  a  v a  2  s  .c  o m*/
    GroundJsonObjectBuilder();

    String dailyTailgateText = createDailyTailgate(name, userSelectedDateGround, submissionDate, reSubmit,
            transitDay, phoneNumber, mobNumber, workingAlone, colleagues, locationStart, gpsLatitude,
            gpsLongitude, hiVisApparel, clothingForSeason, safetyRatedFootwear, personalSurvivalKit,
            hearingProtection, hardHat, ppeComments, rentalVehicle, rentalAgency, vehicleMake, vehicleModel,
            vehicleColour, vehicleLicensePlate, vehicleOperatorName, cityOfDeparture, cityOfArrival,
            projectLocation, projectDescription, estimatedWorkDuration, checkInContactRole, checkInContactName,
            satellitePhone, satellitePhoneNumber, radio, firstAidKit, fireExtinguisher, transportingFuel,
            tdgPlacards, spillKit, workingInTraffic, pylons, trafficSigns, appropriateVehicle, remoteArea,
            workingInIsolation, extremeWeather, transmissionLines, activeMineSite, activeLoggingArea, wildlife,
            fatigue, politicalConflict, riskLevel, preventionMeasures, postRiskLevel, generalComments);

    writeJsonFileToExternalStorage();

    // New email method (attaching .json file instead of .csv)
    File Dir = new File(String.valueOf(getExternalFilesDir(null)) + "/GroundReports");
    String jsonReportTextFileName = "OpenGround_Report.json";
    File jsonReportFile = new File(Dir, jsonReportTextFileName);

    Uri uri = FileProvider.getUriForFile(OpenGroundReport.this, BuildConfig.APPLICATION_ID + ".provider",
            jsonReportFile);

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.email_address) });
    intent.putExtra(Intent.EXTRA_SUBJECT, "Open Ground Report" + "-" + "MOB(" + mobNumber + ")-" + name + "-"
            + userSelectedDateGround + "-" + "Field_Report");
    intent.putExtra(Intent.EXTRA_TEXT, dailyTailgateText);

    if (!jsonReportFile.exists() || !jsonReportFile.canRead()) {
        return;
    }

    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(Intent.createChooser(intent, getString(R.string.pick_email_provider)));
    }
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

public void TrialIsEndingWarningOrLicensingFailed(String verbiage, Boolean wereDealingWithLicensingHere) {
    final Boolean wdwlh = wereDealingWithLicensingHere;
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(verbiage).setCancelable(false)
            .setNeutralButton(R.string.msg_cus, new DialogInterface.OnClickListener() {
                @Override//from  w w  w.  j  a v  a  2  s  . c  o  m
                public void onClick(DialogInterface dialog, int id) {
                    String[] mailto = { "diamondsoftware222@gmail.com", "" };
                    Intent sendIntent = new Intent(Intent.ACTION_SEND);
                    sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
                    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "".toString());
                    sendIntent.putExtra(Intent.EXTRA_TEXT, "".toString());
                    sendIntent.setType("text/plain");
                    startActivity(Intent.createChooser(sendIntent, "Send EMail..."));
                }
            }).setPositiveButton(R.string.msg_register, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    Intent i4 = new Intent(INeedToo.this, INeedToPay.class);
                    startActivity(i4);
                }
            }).setNegativeButton(R.string.msg_cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (wdwlh) {
                        INeedToo.this.finish();
                    }
                }
            });
    AlertDialog alert = builder.create();
    try {
        alert.show();
    } catch (Exception ee33) {
        int bkhere = 3;
        int bkhere2 = bkhere;
    }
}

From source file:nl.mpcjanssen.simpletask.Simpletask.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Task t = getTaskAt(position);//from   w w w .j  a  va2 s . co  m
    final ArrayList<String> actions = new ArrayList<>();
    final ArrayList<String> links = new ArrayList<>();

    for (String link : t.getLinks()) {
        actions.add(ACTION_LINK);
        links.add(link);
    }

    for (String number : t.getPhoneNumbers()) {
        actions.add(ACTION_PHONE);
        links.add(number);
    }

    for (String mail : t.getMailAddresses()) {
        actions.add(ACTION_MAIL);
        links.add(mail);
    }

    final String[] linksArray = links.toArray(new String[0]);
    if (linksArray.length == 0) {
        getListView().setItemChecked(position, !getListView().isItemChecked(position));
    } else {
        AlertDialog.Builder build = new AlertDialog.Builder(this);
        build.setItems(linksArray, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent;
                String url = links.get(which);
                Log.v(TAG, "" + actions.get(which) + ": " + url);
                switch (actions.get(which)) {
                case ACTION_LINK:
                    if (url.startsWith("todo://")) {
                        File todoFolder = m_app.getTodoFile().getParentFile();
                        File newName = new File(todoFolder, url.substring(7));
                        m_app.switchTodoFile(newName);
                    } else {
                        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                        startActivity(intent);
                    }
                    break;
                case ACTION_PHONE:
                    String encodedNumber = Uri.encode(url);
                    intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + encodedNumber));
                    startActivity(intent);
                    break;
                case ACTION_MAIL:
                    intent = new Intent(Intent.ACTION_SEND, Uri.parse(url));
                    intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { url });
                    intent.setType("text/plain");
                    startActivity(intent);

                }
            }
        });
        build.create().show();
    }
    return;
}

From source file:com.intel.xdk.device.Device.java

public void sendEmail(String body, String to, String subject, boolean ishtml, String cc, String bcc) {

    String toArray[] = to.split(",");
    String ccArray[] = cc.split(",");
    String bccArray[] = bcc.split(",");

    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); // it's not ACTION_SEND
    if (ishtml) {
        //Android default mail clients poorly support html formatted mail :(
        //intent.setType("text/html");
        //intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body,null,null));
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, body);
    } else {//  ww  w  .  j a  v  a 2  s  .  c o  m
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    if (toArray.length > 0 && !toArray[0].equals("")) {
        intent.putExtra(Intent.EXTRA_EMAIL, toArray);
    }
    if (ccArray.length > 0 && !ccArray[0].equals("")) {
        intent.putExtra(Intent.EXTRA_CC, ccArray);
    }
    if (bccArray.length > 0 && !bccArray[0].equals("")) {
        intent.putExtra(Intent.EXTRA_BCC, bccArray);
    }

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //return user to app after sending mail
    activity.startActivity(intent);
}

From source file:com.javielinux.utils.Utils.java

public static void sendLastCrash(Activity cnt) {
    try {/*  w  w w . jav a 2  s . c  o  m*/
        Intent gmail = new Intent(Intent.ACTION_VIEW);
        gmail.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
        gmail.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) });
        gmail.setData(Uri.parse(cnt.getString(R.string.email_send_errors)));
        gmail.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash");
        gmail.setType("plain/text");
        gmail.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt));
        cnt.startActivity(gmail);
    } catch (ActivityNotFoundException e) {
        Intent msg = new Intent(Intent.ACTION_SEND);
        msg.putExtra(Intent.EXTRA_EMAIL, new String[] { cnt.getString(R.string.email_send_errors) });
        msg.putExtra(Intent.EXTRA_SUBJECT, "TweetTopics crash");
        msg.setType("plain/text");
        msg.putExtra(Intent.EXTRA_TEXT, ErrorReporter.getErrors(cnt));
        cnt.startActivity(msg);
    }
}

From source file:com.todotxt.todotxttouch.TodoTxtTouch.java

void showContextActionBarIfNeeded() {
    ArrayList<Task> checkedTasks = getCheckedTasks();
    int checkedCount = checkedTasks.size();

    if (inActionMode() && checkedCount == 0) {
        mMode.finish();/*from  w  w  w  . j  av  a2 s  . co m*/

        return;
    } else if (checkedCount == 0) {
        return;
    }

    if (mMode == null) {
        m_swipeList.setEnabled(false);
        mMode = startActionMode(new Callback() {
            @Override
            public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                getSupportMenuInflater().inflate(R.menu.main_long, menu);

                return true;
            }

            @Override
            public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                ArrayList<Task> checkedTasks = getCheckedTasks();
                int menuid = item.getItemId();
                Intent intent;

                switch (menuid) {
                case R.id.update:
                    if (checkedTasks.size() == 1) {
                        editTask(checkedTasks.get(0));
                    } else {
                        Log.w(TAG, "More than one task was selected while handling update menu");
                    }

                    break;
                case R.id.done:
                    completeTasks(checkedTasks, true);

                    break;
                case R.id.priority:
                    prioritizeTasks(checkedTasks);

                    break;
                case R.id.share:
                    shareTasks(checkedTasks);

                    break;
                case R.id.calendar:
                    addToCalendar(checkedTasks);

                    break;
                case R.id.uncomplete:
                    undoCompleteTasks(checkedTasks, true);

                    break;
                case R.id.delete:
                    deleteTasks(checkedTasks);

                    break;
                case R.id.url:
                    Log.v(TAG, "url: " + item.getTitle().toString());

                    intent = new Intent(Intent.ACTION_VIEW, Uri.parse(item.getTitle().toString()));
                    startActivity(intent);

                    break;
                case R.id.mail:
                    Log.v(TAG, "mail: " + item.getTitle().toString());

                    intent = new Intent(Intent.ACTION_SEND, Uri.parse(item.getTitle().toString()));
                    intent.putExtra(android.content.Intent.EXTRA_EMAIL,
                            new String[] { item.getTitle().toString() });
                    intent.setType("text/plain");
                    startActivity(intent);

                    break;
                case R.id.phone_number:
                    Log.v(TAG, "phone_number");

                    intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + item.getTitle().toString()));
                    startActivity(intent);

                    break;
                default:
                    Log.w(TAG, "unrecognized menuItem: " + menuid);
                }

                mMode.finish();

                return true;
            }

            @Override
            public void onDestroyActionMode(ActionMode mode) {
                getListView().clearChoices();
                m_adapter.notifyDataSetChanged();
                m_swipeList.setEnabled(true);
                mMode = null;
            }
        });
    }
    mMode.setTitle(checkedCount + " " + getString(R.string.selected));
    Menu menu = mMode.getMenu();
    MenuItem updateAction = menu.findItem(R.id.update);
    MenuItem completeAction = menu.findItem(R.id.done);
    MenuItem uncompleteAction = menu.findItem(R.id.uncomplete);

    // Only show update action with a single task selected
    if (checkedCount == 1) {
        updateAction.setVisible(true);
        Task task = checkedTasks.get(0);

        if (task.isCompleted()) {
            completeAction.setVisible(false);
        } else {
            uncompleteAction.setVisible(false);
        }

        for (URL url : task.getLinks()) {
            menu.add(Menu.CATEGORY_SECONDARY, R.id.url, Menu.NONE, url.toString());
        }

        for (String s1 : task.getMailAddresses()) {
            menu.add(Menu.CATEGORY_SECONDARY, R.id.mail, Menu.NONE, s1);
        }

        for (String s : task.getPhoneNumbers()) {
            menu.add(Menu.CATEGORY_SECONDARY, R.id.phone_number, Menu.NONE, s);
        }
    } else {
        updateAction.setVisible(false);
        completeAction.setVisible(true);
        uncompleteAction.setVisible(true);
        menu.removeGroup(Menu.CATEGORY_SECONDARY);
    }
}