Skip to content Skip to sidebar Skip to footer

Use Action_send To Send Email Directly By Gmail, Not Choose From Action-list

I read this question to know how to send email in Android using ACTION_SEND: Sending email from android app But problem is: I want to send email directly using Gmail, i don't want

Solution 1:

How to open Gmail Compose when a button is clicked in Android App? the second answer of beekeeper. Also duplicate of how to direct open Gmail mail composer in android? which has the same answer.

Solution 2:

Try this:

finalIntentintent=newIntent (android.content.Intent.ACTION_SEND);
    intent.setType ("text/plain");
    List<ResolveInfo> resInfo = getPackageManager ().queryIntentActivities (intent, 0);

    if (!resInfo.isEmpty ()) {
        for (ResolveInfo info : resInfo) {
            if (info.activityInfo.packageName.toLowerCase ().contains ("android.gm") || info.activityInfo.name.toLowerCase ().contains ("android.gm")) {


                intent.putExtra(android.content.Intent.EXTRA_EMAIL, newString[]{email});
                intent.putExtra(android.content.Intent.EXTRA_SUBJECT, TextKonnex);
                intent.putExtra(android.content.Intent.EXTRA_TEXT, message);
                intent.setPackage (info.activityInfo.packageName);

                try {
                    startActivity (android.content.Intent.createChooser (intent,"Sending..."));
                    Toast.makeText(Main4Activity.this, "Sending an email to your friend! ", Toast.LENGTH_LONG).show();
                } catch (ActivityNotFoundException e) {


                    Toast.makeText(Main4Activity.this, "Error! Try whith other email address! ", Toast.LENGTH_LONG).show();
                }


            }
        }

Post a Comment for "Use Action_send To Send Email Directly By Gmail, Not Choose From Action-list"