在Android中使用Gmail发送电子邮件 [英] Sending email using GMail in android
本文介绍了在Android中使用Gmail发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图打开电子邮件发送的Gmail中直接单击按钮形式,但这种始终显示的选项,发送电子邮件列表。
I am trying to open email sending form of Gmail directly on button click but this always shows a list of options for sending email.
我这样做是为打开GMail的形式:
I am doing this for opening 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" ));
但这是不开放的Gmail形式。我能做些什么来打开GMail的形式,请帮助。
but this is not opening GMail form. What can i do for opening GMail form please help.
有没有办法做到这一点?
Is there any way to do this?
推荐答案
使用的东西就行
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
}
}
这篇关于在Android中使用Gmail发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文