简体   繁体   English

Android-是否有一种万无一失的方式仅显示可能的EMAIL客户?

[英]Android - Is there a foolproof way to only show possible EMAIL clients?

In android, you can send an email via the Intent.ACTION_SEND intent, but this will bring up messaging and other things (even if you specify a type of text/plain). 在android中,您可以通过Intent.ACTION_SEND意向发送电子邮件,但这将显示消息传递和其他内容(即使您指定了文本/纯文本类型)。

If you want to the user to only see possible EMAIL clients, is there a foolproof, robust way to do that? 如果您希望用户仅查看可能的EMAIL客户端,是否有一种万无一失,强大的方法来做到这一点?

Use ACTION_SENDTO and a mailto: Uri pointing to the email address you want. 使用ACTION_SENDTOmailto: Uri指向所需的电子邮件地址。

If you do not have an email address, then your app should not be trying to limit the user to email. 如果您没有电子邮件地址,则您的应用不应尝试限制用户发送电子邮件。 Please let the user share what the user wants how the user wants. 请让用户分享用户想要的东西。

BTW, the MIME type is text/plain , not plain/text . 顺便说一句,MIME类型是text/plain ,而不是plain/text There's a snippet for ACTION_SEND floating around that has the wrong MIME type. 有一个用于ACTION_SEND的代码段,该代码段具有错误的MIME类型。

The short answer is no, any application can have itself listed. 简短的答案是不,任何应用程序都可以列出自己。 The system looks for Intent Filters that match what application can handle it. 系统会寻找与应用程序可以处理的内容匹配的意图过滤器。 With experimentation you may be able to reduce the number of applications that say it can handle the intent or you could try to make an explicit Intent, directing directly at GMail or EMail, etc. 通过实验,您可能能够减少表示可以处理该意图的应用程序的数量,或者尝试直接在GMail或EMail等处创建明确的Intent。

Have you tried message/rfc822 as the MIME type? 您是否尝试过将message/rfc822作为MIME类型?
See first comment: http://mobile.tutsplus.com/tutorials/android/android-email-intent/ 看到第一条评论: http : //mobile.tutsplus.com/tutorials/android/android-email-intent/
See also this: Send an email in Android selecting only email apps AND specifying attachment mime type 另请参阅: 在Android中发送电子邮件,仅选择电子邮件应用程序并指定附件mime类型

That narrows down to Gmail and Bluetooth in my phone. 这将范围缩小到我手机中的Gmail和蓝牙。 message/partial seems to do the same. message/partial似乎也是如此。

I don't know if this works for all phones but seems to be a viable alternative. 我不知道这是否适用于所有手机,但似乎是一个可行的选择。


Here's test code: 这是测试代码:

private void sendEmail()
{
    Intent intent = new Intent(Intent.ACTION_SEND);

    intent.putExtra(Intent.EXTRA_EMAIL, "foo.bar@invalid.com");
    intent.putExtra(Intent.EXTRA_SUBJECT, "From Test app");
    intent.putExtra(Intent.EXTRA_TEXT, "Test test test");
    intent.setType("message/rfc822");

    startActivity(intent);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ANDROID | 仅通过电子邮件客户端发送电子邮件附件 - ANDROID | send email attachment only with email clients 获取Android用户个人电话号码的万无一失的方法? - Foolproof way to get Android User's Personal Phone Number? 目标Android电子邮件客户端? - Target Android Email Clients? 如何仅通过我的Android应用程序中的电子邮件客户端发送邮件 - How to send mail only through email clients in my android application 是否可以仅针对某个 android 版本显示小部件? - is it possible to show widget only for a certain android version? 当我想查看 Android 上的所有 email 客户端时,我只看到 3 个选项 - I see only 3 options when I want to see all the email clients on Android 检测是否启用了开发人员选项的万无一失的方法? - Foolproof way to detect if developer options are enabled? 是否可以使用Android SDK扫描无线客户端? - Is it possible to scan for wireless clients using the Android SDK? 在 Android 中,是否可以使用 WebView 仅显示 html 元素的特定 ID - In Android is it possible to only show a specific ID of an html element using WebView 是否可以在 android firebase 上仅显示特定用户 ID 的数据? - Is it possible to show only the data on the specific user id on android firebase?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM