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:org.gnucash.android.export.ExporterTask.java

/**
 * Starts an intent chooser to allow the user to select an activity to receive
 * the exported OFX file//  w w w  . j av  a 2  s  . co  m
 * @param path String path to the file on disk
 */
private void shareFile(String path) {
    String defaultEmail = PreferenceManager.getDefaultSharedPreferences(mContext)
            .getString(mContext.getString(R.string.key_default_export_email), null);
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("application/xml");
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path));
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, mContext.getString(R.string.title_export_email));
    if (defaultEmail != null && defaultEmail.trim().length() > 0) {
        shareIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { defaultEmail });
    }
    SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateTimeInstance();

    shareIntent.putExtra(Intent.EXTRA_TEXT, mContext.getString(R.string.description_export_email) + " "
            + formatter.format(new Date(System.currentTimeMillis())));

    mContext.startActivity(
            Intent.createChooser(shareIntent, mContext.getString(R.string.title_select_export_destination)));
}

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;// w ww .  ja  va  2 s.c om
    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:org.easyrpg.player.player.EasyRpgPlayerActivity.java

private void reportBug() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setTitle(R.string.app_name);

    final SpannableString bug_msg = new SpannableString(
            getApplicationContext().getString(R.string.report_bug_msg));
    Linkify.addLinks(bug_msg, Linkify.ALL);

    // set dialog message
    alertDialogBuilder.setMessage(bug_msg).setCancelable(false)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ArrayList<Uri> files = new ArrayList<Uri>();
                    String savepath = getIntent().getStringExtra(TAG_SAVE_PATH);
                    files.add(Uri.fromFile(new File(savepath + "/easyrpg_log.txt")));
                    for (File f : GameBrowserHelper.getSavegames(new File(savepath))) {
                        files.add(Uri.fromFile(f));
                    }//from   w ww  . jav  a  2s.c  o m

                    if (Build.VERSION.SDK_INT >= 24) {
                        // Lazy workaround as suggested on https://stackoverflow.com/q/38200282
                        try {
                            Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
                            m.invoke(null);
                        } catch (Exception e) {
                            Log.i("EasyRPG", "Bug report: Calling disableDeathOnFileUriExposure failed");
                        }
                    }

                    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
                    intent.setData(Uri.parse("mailto:"));
                    intent.setType("*/*");
                    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "easyrpg@easyrpg.org" });
                    intent.putExtra(Intent.EXTRA_SUBJECT, "Bug report");
                    intent.putExtra(Intent.EXTRA_TEXT,
                            getApplicationContext().getString(R.string.report_bug_mail));
                    intent.putExtra(Intent.EXTRA_STREAM, files);
                    if (intent.resolveActivity(getPackageManager()) != null) {
                        startActivity(intent);
                    }
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();

    alertDialog.show();

    ((TextView) alertDialog.findViewById(android.R.id.message))
            .setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.friedran.appengine.dashboard.gui.DashboardActivity.java

private void sendFeedback() {
    final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("text/html");
    intent.putExtra(android.content.Intent.EXTRA_EMAIL,
            new String[] { getString(R.string.mail_feedback_address) });
    intent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.mail_feedback_subject));
    intent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.mail_feedback_message));
    startActivity(Intent.createChooser(intent, getString(R.string.title_send_feedback)));
}

From source file:com.game.simple.Game3.java

public static void sendEmail(String address, String subject, String content) {
    //---timer---//
    //StartReConnect();
    //-----------//
    String[] _address = { address.toString() };
    Intent email = new Intent(Intent.ACTION_SEND);
    email.putExtra(Intent.EXTRA_EMAIL, _address);
    email.putExtra(Intent.EXTRA_SUBJECT, subject);
    email.putExtra(Intent.EXTRA_TEXT, content);
    email.setType("message/rfc822");
    self.startActivity(Intent.createChooser(email, "Choose an Email client :"));

}

From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java

private void sendEmail(ArrayList<SecretCode> secretCodes) {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("message/rfc822");
    i.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.extra_email) });
    i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.extra_subject));
    i.putExtra(Intent.EXTRA_TEXT, generateEmailBody(secretCodes));
    i.putExtra(Intent.EXTRA_STREAM, ExportContentProvider.CONTENT_URI);
    startActivity(Intent.createChooser(i, null));
}

From source file:edu.rutgers.winlab.crowdpp.ui.SettingsFragment.java

@Override
public void onListItemClick(ListView l, final View v, int position, long id) {
    switch ((int) id) {
    case 0:/*from   ww  w .  ja v  a2 s .  c o  m*/
        new AlertDialog.Builder(getActivity()).setTitle("Start time")
                .setSingleChoiceItems(Arrays.copyOfRange(hours_arr, 0, hours_arr.length - 1), 0,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                tv_peroid = (TextView) v.findViewById(R.id.tv_settings_choice);
                                temp_str = hours_arr[which].substring(0, hours_arr[which].indexOf(':'));
                                editor.putString("start", temp_str);
                                temp_str.concat(" - ");
                                temp_hour = which;
                                dialog.dismiss();
                                final String[] temp_hours = Arrays.copyOfRange(hours_arr, temp_hour + 1,
                                        hours_arr.length);
                                new AlertDialog.Builder(getActivity()).setTitle("End time")
                                        .setSingleChoiceItems(temp_hours, 0,
                                                new DialogInterface.OnClickListener() {
                                                    @Override
                                                    public void onClick(DialogInterface dialog, int which) {
                                                        editor.putString("end", temp_hours[which].substring(0,
                                                                temp_hours[which].indexOf(':')));
                                                        temp_str = temp_str.concat(" to ")
                                                                .concat(temp_hours[which].substring(0,
                                                                        temp_hours[which].indexOf(':')));
                                                        tv_peroid.setText(temp_str);
                                                        dialog.dismiss();
                                                        editor.commit();
                                                        Toast.makeText(getActivity(),
                                                                "You need to restart the service to apply these changes",
                                                                Toast.LENGTH_SHORT).show();
                                                    }
                                                })
                                        .show();
                            }
                        })
                .show();
        break;

    case 1:
        new AlertDialog.Builder(getActivity()).setTitle(title[(int) id])
                .setSingleChoiceItems(interval_arr, 0, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        temp_interval = which;
                        tv_interval = (TextView) v.findViewById(R.id.tv_settings_choice);
                        temp_str = interval_arr[which].substring(0, interval_arr[which].indexOf(' '));
                        tv_interval.setText(temp_str.concat(" Min"));
                        Log.i("Debug", temp_str.concat(" Min"));
                        editor.putString("interval", temp_str);
                        editor.commit();
                        dialog.dismiss();
                        Toast.makeText(getActivity(), "You need to restart the service to apply these changes",
                                Toast.LENGTH_SHORT).show();
                    }
                }).show();
        break;

    case 2:
        new AlertDialog.Builder(getActivity()).setTitle(title[(int) id])
                .setSingleChoiceItems(duration_arrs[temp_interval], 0, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        tv_duration = (TextView) v.findViewById(R.id.tv_settings_choice);
                        temp_str = duration_arrs[temp_interval][which].substring(0,
                                duration_arrs[temp_interval][which].indexOf(' '));
                        tv_duration.setText(temp_str.concat(" Min"));
                        Log.i("Debug", temp_str.concat(" Min"));

                        editor.putString("duration", temp_str);
                        editor.commit();
                        dialog.dismiss();
                        Toast.makeText(getActivity(), "You need to restart the service to apply these changes",
                                Toast.LENGTH_SHORT).show();
                    }
                }).show();
        break;

    case 3:
        new AlertDialog.Builder(getActivity()).setTitle(title[(int) id])
                .setSingleChoiceItems(location_enable, 0, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        tv_location = (TextView) v.findViewById(R.id.tv_settings_choice);
                        temp_str = location_enable[which];
                        tv_location.setText(temp_str);
                        Log.i("Debug", temp_str);
                        editor.putString("location", temp_str);
                        editor.commit();
                        dialog.dismiss();
                        Toast.makeText(getActivity(), "You need to restart the service to apply these changes",
                                Toast.LENGTH_SHORT).show();
                    }
                }).show();
        break;

    case 4:
        new AlertDialog.Builder(getActivity()).setTitle(title[(int) id])
                .setSingleChoiceItems(upload_enable, 0, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        tv_upload = (TextView) v.findViewById(R.id.tv_settings_choice);
                        temp_str = upload_enable[which];
                        tv_upload.setText(temp_str);
                        editor.putString("upload", temp_str);
                        editor.commit();
                        dialog.dismiss();
                        Toast.makeText(getActivity(), "You need to restart the service to apply these changes",
                                Toast.LENGTH_SHORT).show();
                    }
                }).show();
        break;

    case 5:
        Intent webIntent = new Intent("android.intent.action.VIEW",
                Uri.parse("https://github.com/lendlice/crowdpp"));
        startActivity(webIntent);
        break;

    case 6:
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "chenren.xu@gmail.com" });
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Crowd++ bug report");
        sendIntent.setType("message/rfc822");
        startActivity(Intent.createChooser(sendIntent, "Send via"));
        break;

    default:
        break;
    }
}

From source file:com.jwork.dhammapada.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    log.v(this, "onOptionsItemSelected(" + item.getTitle() + ")");
    String appName = getString(R.string.app_name);
    String appPackage = getPackageName();
    switch (item.getItemId()) {
    case R.id.action_rate:
        Uri uri = Uri.parse("market://details?id=" + appPackage);
        Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
        try {//from w ww  .j  a  v a2  s  .  c  om
            startActivity(myAppLinkToMarket);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Failed to find Market application", Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.action_donate:
        openDonate();
        break;
    case R.id.action_share:
        Intent intentText = new Intent(Intent.ACTION_SEND);
        intentText.setType("text/plain");
        intentText.putExtra(Intent.EXTRA_SUBJECT, appName);
        intentText.putExtra(Intent.EXTRA_TEXT, "Check out " + appName
                + " on Google Play! https://play.google.com/store/apps/details?id=" + appPackage);
        try {
            startActivity(Intent.createChooser(intentText, getString(R.string.share_this_app_intent)));
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Failed to share this application", Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.action_about:
        aboutWindow.showAtLocation(this.findViewById(R.id.mainLayout), Gravity.CENTER, 0, 0);
        mainLayout.getForeground().setAlpha(200);
        break;
    case R.id.action_feedback:
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        String subject = "[" + Constant.APP_NAME + "] Feedback";
        sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "jwork.dhammapada.os@gmail.com" });
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        sendIntent.putExtra(Intent.EXTRA_TEXT,
                "\n-------------------------------\n" + CrashHandler.getPhoneInfo(this));
        sendIntent.setType("message/rfc822");
        startActivity(Intent.createChooser(sendIntent, "Email:"));
        break;
    }
    // TODO Auto-generated method stub
    return super.onContextItemSelected(item);
}

From source file:com.eyekabob.util.EyekabobHelper.java

public static void launchEmail(Activity activity) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("plain/text");
    String to[] = { "philj21@yahoo.com", "adam.sill01@gmail.com", "coffbr01@gmail.com" };
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Eyekabob Advertising");
    String label = activity.getResources().getString(R.string.write_email);
    activity.startActivity(Intent.createChooser(emailIntent, label));
}

From source file:ru.neverdark.phototools.fragments.TitlesFragment.java

/**
 * Sends email to application author//from  w ww . j a  v  a 2  s.  c o m
 */
private void sendEmail() {
    Intent mailIntent = new Intent(Intent.ACTION_SEND);
    mailIntent.setType("plain/text");
    mailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.titles_emailAuthor) });
    mailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
    startActivity(Intent.createChooser(mailIntent, getString(R.string.titles_selectEmailApplication)));
}