Sending email using GMail in android

I am trying to open the Gmail email sending form directly at the click of a button, but this always shows a list of email sending options.

I do this to open the GMail form:

Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND); String[] recipients = new String[]{"" , "" ,}; emailIntent.putExtra( android.content.Intent.EXTRA_EMAIL, recipients); emailIntent.putExtra( android.content.Intent.EXTRA_SUBJECT, "This is my text" ); emailIntent.putExtra( android.content.Intent.EXTRA_TEXT, ""); emailIntent.setType("message/rfc822"); startActivity( Intent.createChooser(emailIntent, "Send Email" )); 

but this is not a discovery of the GMail form. What can I do to open the GMail form, please help.

Is there any way to do this?

+7
source share
1 answer

use something on the lines

 public void sendGmail(Activity activity, String subject, String text) { Intent gmailIntent = new Intent(); gmailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail"); gmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); gmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, text); try { activity.startActivity(gmailIntent); } catch(ActivityNotFoundException ex) { // handle error } } 
+16
source

All Articles