我想实现一个发送电子邮件的选项。现在我可以发送电子邮件,但问题是,Android 显示了许多可以发送的应用程序,例如蓝牙、facebook、消息等,但这些不是必需的。我需要避免这种情况并仅显示电子邮件客户端应用程序。
Intent intent = new Intent(Intent.ACTION_SEND);
String[] emails = {"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1360666176607b3d707b727d77727d7a53747e727a7f3d707c7e" rel="noreferrer noopener nofollow">[email protected]</a>"};
intent.putExtra(Intent.EXTRA_EMAIL, emails);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(Intent.EXTRA_SUBJECT, "Test App");
intent.putExtra(Intent.EXTRA_TEXT, "Email Body");
intent.setType("message/rfc822");
startActivity(intent);
如果有人知道如何实现这一目标,请告诉我
最佳答案
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3447414651475c1a575c555a50555a5d745359555d581a575b59" rel="noreferrer noopener nofollow">[email protected]</a>);
intent.putExtra(Intent.EXTRA_SUBJECT, "Test App");
intent.putExtra(Intent.EXTRA_TEXT, "Email Body");
startActivity(intent);
信用归Adams Bros Blogs但他在帖子中确实提到这仅适用于他的 Gmail。看看你是否成功了。他确实展示了另一种对他有效的方法。
关于android - 仅使用 Android 中的电子邮件客户端应用程序发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11672002/