使用没有选择器的标准gmail应用发送电子邮件 [英] Sending email using standard gmail app without chooser
本文介绍了使用没有选择器的标准gmail应用发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用标准gmail应用程序从我的应用程序发送电子邮件. 但是我一直都有选择器. 如何在没有选择器的情况下立即打开标准gmail应用程序? 我不需要可以发送电子邮件的任何应用程序的选择器. 我只需要GMAIL. 谢谢! 这是我的代码.
I'm trying send email from my app using standard gmail app. But I get chooser all the time. How can I open standard gmail app immediately without chooser? I don't need a chooser with any application which can send email. I need only GMAIL. Thank you! Here is my code.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.setClassName("com.google.android.gm", "com.google.android.gm.ConversationListActivity");
intent.putExtra(Intent.EXTRA_EMAIL , new String[]{"mymail@gmail.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT , "Text");
try {
startActivity(intent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
推荐答案
可以尝试使用此代码.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.setType("plain/text");
emailIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"someone@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Yo");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi");
startActivity(emailIntent);
这篇关于使用没有选择器的标准gmail应用发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文