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:com.renard.ocr.main_menu.ContactActivity.java

public static Intent getFeedbackIntent(Context context, String subject, File file, String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    if (subject != null) {
        intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    }/*  w  ww.  j  a  va 2s  . c o m*/
    if (file.exists()) {
        final Uri uriForFile = FileProvider.getUriForFile(context,
                context.getString(R.string.config_share_file_auth), file);
        intent.putExtra(Intent.EXTRA_STREAM, uriForFile);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }
    if (body != null) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { FEEDBACK_MAIL });
    return intent;
}

From source file:com.renard.ocr.help.ContactActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contact);
    // Show the Up button in the action bar.
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    TextView email = (TextView) findViewById(R.id.textView_send_mail);
    email.setOnClickListener(new OnClickListener() {

        @Override//  w  w w  .j  a  v a 2 s .  co m
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("message/rfc822");
            intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "text fairy feedback");
            intent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { "renard.wellnitz+textfairy@googlemail.com" });
            startActivity(intent);
        }
    });

}

From source file:com.github.pennyfive.cinemafinlando.ui.activity.AboutActivity.java

@OnClick(R.id.email)
public void onEmailClicked() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { BuildConfig.CONTACT_EMAIL });
    startActivity(intent);//w w  w. jav a 2s  .  c o m
}

From source file:org.totschnig.myexpenses.activity.CommonCommands.java

static boolean dispatchCommand(Activity ctx, int command, Object tag) {
    Intent i;/*from w  w w . j a  v  a 2  s  .  c o m*/
    switch (command) {
    case R.id.RATE_COMMAND:
        i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(MyApplication.getMarketSelfUri()));
        if (Utils.isIntentAvailable(ctx, i)) {
            ctx.startActivity(i);
        } else {
            Toast.makeText(ctx, R.string.error_accessing_market, Toast.LENGTH_LONG).show();
        }
        return true;
    case R.id.SETTINGS_COMMAND:
        i = new Intent(ctx, MyPreferenceActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (tag != null) {
            i.putExtra(MyPreferenceActivity.KEY_OPEN_PREF_KEY, (String) tag);
        }
        ctx.startActivityForResult(i, ProtectedFragmentActivity.PREFERENCES_REQUEST);
        return true;
    case R.id.FEEDBACK_COMMAND:
        i = new Intent(android.content.Intent.ACTION_SEND);
        i.setType("plain/text");
        i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { MyApplication.FEEDBACK_EMAIL });
        i.putExtra(android.content.Intent.EXTRA_SUBJECT, "[" + ctx.getString(R.string.app_name) + "] Feedback");
        i.putExtra(android.content.Intent.EXTRA_TEXT,
                getVersionInfo(ctx) + "\n" + ctx.getString(R.string.feedback_email_message));
        if (!Utils.isIntentAvailable(ctx, i)) {
            Toast.makeText(ctx, R.string.no_app_handling_email_available, Toast.LENGTH_LONG).show();
        } else {
            ctx.startActivity(i);
        }
        break;
    case R.id.CONTRIB_INFO_COMMAND:
        CommonCommands.showContribInfoDialog((FragmentActivity) ctx, -1);
        return true;
    case R.id.WEB_COMMAND:
        i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(ctx.getString(R.string.website)));
        ctx.startActivity(i);
        return true;
    case R.id.HELP_COMMAND:
        i = new Intent(ctx, Help.class);
        i.putExtra(HelpDialogFragment.KEY_VARIANT,
                tag != null ? (Enum<?>) tag : ((ProtectedFragmentActivity) ctx).helpVariant);
        //for result is needed since it allows us to inspect the calling activity
        ctx.startActivityForResult(i, 0);
        return true;
    case R.id.REQUEST_LICENCE_COMMAND:
        String androidId = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.ANDROID_ID);
        i = new Intent(android.content.Intent.ACTION_SEND);
        i.setType("plain/text");
        i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { MyApplication.FEEDBACK_EMAIL });
        i.putExtra(android.content.Intent.EXTRA_SUBJECT,
                "[" + ctx.getString(R.string.app_name) + "] " + ctx.getString(R.string.contrib_key));
        String extraText = ctx.getString(R.string.request_licence_mail_head, androidId);
        if (tag != null) {
            extraText += " \n\n[" + ctx.getString(R.string.paypal_transaction_id) + ": " + tag + "]";
        }
        i.putExtra(android.content.Intent.EXTRA_TEXT, extraText);
        if (!Utils.isIntentAvailable(ctx, i)) {
            Toast.makeText(ctx, R.string.no_app_handling_email_available, Toast.LENGTH_LONG).show();
        } else {
            ctx.startActivity(i);
        }
        return true;
    case R.id.VERIFY_LICENCE_COMMAND:
        HashLicenceHandler licenceHandler = (HashLicenceHandler) MyApplication.getInstance()
                .getLicenceHandler();
        LicenceHandler.LicenceStatus licenceStatus = licenceHandler.verifyLicenceKey();
        if (licenceStatus != null) {
            Toast.makeText(ctx,
                    Utils.concatResStrings(ctx, " ", R.string.licence_validation_success,
                            (licenceStatus == LicenceHandler.LicenceStatus.EXTENDED
                                    ? R.string.licence_validation_extended
                                    : R.string.licence_validation_premium)),
                    Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(ctx, R.string.licence_validation_failure, Toast.LENGTH_LONG).show();
        }
        licenceHandler.invalidate();
        return true;
    case android.R.id.home:
        ctx.setResult(FragmentActivity.RESULT_CANCELED);
        ctx.finish();
        return true;
    }
    return false;
}

From source file:hu.naturlecso.naturshutd.dialog.AboutDialogFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.dialog_about, container, false);

    // set title/*from  ww w  . ja  v a2s .  co  m*/
    String title;
    try {
        title = getString(R.string.app_name) + " " + getActivity().getPackageManager()
                .getPackageInfo(getActivity().getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        title = "";
    }
    getDialog().setTitle(title);

    // handle button clicks
    rootView.findViewById(R.id.dialog_about_contact).setOnClickListener(v -> {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("message/rfc822");
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.dialog_about_contact_email) });
        intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.dialog_about_contact_subject));
        startActivity(Intent.createChooser(intent, getString(R.string.dialog_about_contact)));
    });

    rootView.findViewById(R.id.dialog_about_license).setOnClickListener(v -> {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(getString(R.string.dialog_about_license_url)));
        startActivity(intent);
    });

    return rootView;
}

From source file:com.app.common.util.IntentUtils.java

public static void startEmailActivity(Context context, String to, String subject, String body) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");

    if (!TextUtils.isEmpty(to)) {
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
    }// w  w w  .  j a  va 2  s  .  c  om
    if (!TextUtils.isEmpty(subject)) {
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    }
    if (!TextUtils.isEmpty(body)) {
        intent.putExtra(Intent.EXTRA_TEXT, body);
    }

    final PackageManager pm = (PackageManager) context.getPackageManager();
    try {
        if (pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) {
            intent.setType("text/plain");
        }
    } catch (Exception e) {
        Log.w("Exception encountered while looking for email intent receiver.", e);
    }

    context.startActivity(intent);
}

From source file:net.tjohns.badgescanner.BaseActivity.java

public void reportIssue() {
    Intent i = new Intent(android.content.Intent.ACTION_SEND);
    i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "badgescanner-bugs@tjohns.net" });
    i.putExtra(android.content.Intent.EXTRA_SUBJECT, "[BadgeScanner] Issue Report");
    i.setType("text/plain");
    i.putExtra(android.content.Intent.EXTRA_TEXT,
            "Summary:\n\nSteps to reproduce:\n\nAdditional information:\n");
    startActivity(Intent.createChooser(i, "Select Mail Client"));
}

From source file:com.kyat.DJbooth.MainActivity.java

public void reportBug(View reportBug) {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("message/rfc822");
    i.putExtra(Intent.EXTRA_EMAIL, new String[] { getResources().getString(R.string.contactEmail) });
    i.putExtra(Intent.EXTRA_SUBJECT, "RMT Tools Feedback");
    i.putExtra(Intent.EXTRA_TEXT, "Your feedback here...");
    try {/*ww w.  j a v a 2 s .  com*/
        startActivity(Intent.createChooser(i, "Send Feedback"));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }
}

From source file:de.sourcestream.movieDB.About.java

/**
 * Fired when clicked on Sourcestream or TMDB logo.
 *
 * @param v the view from which the event has been fired.
 *///from   w w w  .j a v a 2s.c  o  m
@Override
public void onClick(View v) {
    //Get url from tag
    if (v.getId() == R.id.aboutSupportMail) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("message/rfc822");
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "info@sourcestream.de" });
        intent.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.MailSubject));
        intent.putExtra(Intent.EXTRA_TEXT, res.getString(R.string.MailDesc));
        startActivity(Intent.createChooser(intent, res.getString(R.string.MailSend)));
    } else {
        String url = (String) v.getTag();

        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);

        //pass the url to intent data
        intent.setData(Uri.parse(url));

        startActivity(intent);
    }
}

From source file:com.idt.ontomedia.geoconsum.BaseActivity.java

@Override
public boolean onMenuItemSelected(int _featureId, MenuItem _item) {
    switch (_item.getItemId()) {
    case REPORT_BUG_ITEM_ID: {
        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("plain/text");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                new String[] { this.getResources().getString(R.string.report_bug_emailto) });
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                this.getResources().getString(R.string.report_bug_subject));
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                mErrorInfo + this.getResources().getString(R.string.report_bug_body));
        this.startActivity(
                Intent.createChooser(emailIntent, this.getResources().getString(R.string.report_bug_selector)));

        break;//from   w  ww  .jav a2 s  .  c  o m
    }
    case ABOUT_ITEM_ID: {
        showDialog(DIALOG_ABOUT_ID);
        break;
    }
    case PREFERENCES_ITEM_ID: {
        startActivity(new Intent(this, DialogPreferenceActivity.class));
        break;
    }
    }
    return super.onMenuItemSelected(_featureId, _item);
}