android - 仅使用 Android 中的电子邮件客户端应用程序发送电子邮件

标签 android email android-intent

我想实现一个发送电子邮件的选项。现在我可以发送电子邮件,但问题是,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/

相关文章:

android - 从代码中拉伸(stretch)按钮图像的图像

email - 为什么激活电子邮件有用?

android:alwaysRetainTaskState = false 不被尊重,任务状态始终保留

android - 多个 Intent 绑定(bind)到 appwidget 中的一个按钮?

java - Realm 和 jackOptions Java 以非零退出值 1 完成 - Android Gradle

android - 在 Kotlin 中调用 String 方法当 block

Android 这个(上下文)给出 NullPointerException

c# - 通过 asp.net 3.5 发送电子邮件

php - 如何在 Mailjet v3 PHP 包装器中获取联系人 ID?

Android从 Activity 更改铃声