如何获取设备中存储的用户自己的电子邮件地址?

发布于 2024-10-19 05:49:24 字数 1028 浏览 1 评论 0原文

我需要检索存储在设备中的用户的所有电子邮件地址(不是他朋友的电子邮件地址,而是他自己的电子邮件地址)。 例如,如果我有三个邮件地址 [电子邮件受保护],< a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0364666f77717a437a626b6c6c2d606c2d7668">[电子邮件受保护] 和 [email protected],我正在寻找一种返回具有以下三个字符串的数组(或类似数组)的方法:["< a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3156545d454344555471565c50585d1f525e5c">[电子邮件受保护]", "[电子邮件受保护]", "[电子邮件受保护]"]。 有什么想法吗?

编辑:我想获取存储在设备上“我”联系人中的电子邮件地址,以及存储在默认邮件应用程序和 gmail 客户端应用程序中的自己的电子邮件地址(我认为这是默认使用的应用程序) 。 提前致谢。 G。

I need to retrieve all the email addresses of the user, stored in the device (not the email addresses of his friends, but his OWN email addresses).
For example, if I've three mail addresses [email protected], [email protected] and [email protected], i'm looking for a method that returns an array (or similar) with these three Strings: ["[email protected]", "[email protected]", "[email protected]"].
Any idea?

Edit: I'd like to get the email addresses stored in the "me" contact on the device, plus the own email addresses stored in the default mail app and in the gmail client app (that are the default used apps, I think).
Thanks in advance.
G.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痕至 2024-10-26 05:49:24

这些地址大部分由电子邮件客户端维护,没有内容提供商可以获取这些地址。

如果您的目标是使用地址列表来选择外发电子邮件的返回地址,那么这不符合 Android 的处理方式。您的应用程序应该通过抛出正确配置的 ACTION_SEND 意图来声明它想要发送电子邮件。无论应用程序最终提供什么服务,它都可以让用户选择在发送时使用哪个帐户和返回地址。


附录:

默认电子邮件客户端有一个名为 content://com.android.email.provider/account 的内容提供程序,您不应该或不能使用它,因为:

  • 它没有记录。
  • 其清单要求想要使用它的应用程序具有com.android.email.permission.ACCESS_PROVIDER权限。
  • 该权限的 protectionLevelsignatureOrSystem,它限制对存储在系统映像中或使用与系统映像中相同密钥签名的应用程序的授权。您的应用程序不太可能属于这些类别中的任何一个。

其他需要注意的事项:

  • 不能保证给定设备将支持电子邮件。
  • 设备上的电子邮件可能由第三方电子邮件客户端(例如,K9、SEVEN、Touchdown、MailDroid 或其他)提供服务,这些客户端维护自己的帐户数据库并且可能不会公开它。

Most of those addresses are maintained by email clients which don't have content providers to get at them.

If your goal is to use the address list to select the return address for an outgoing email, that doesn't fit the Android way of doing things. Your application should announce that it wants to send an email by throwing out a properly-outfitted ACTION_SEND intent. Whatever application ultimately services it may give the user a choice about which account and return address to use in sending it.


Addendum:

The default email client has a content provider called content://com.android.email.provider/account that you shouldn't or can't use because:

  • It's undocumented.
  • Its manifest requires that apps wanting to use it have the com.android.email.permission.ACCESS_PROVIDER permission.
  • That permission has a protectionLevel of signatureOrSystem, which restricts grants to apps stored in the system image or signed with the same key as those in the system image. Your application is unlikely to fall into either of those categories.

Other things to be aware of:

  • There is no guarantee that a given device will have support for email.
  • Email on a device may be serviced by a third-party email client (e.g., K9, SEVEN, Touchdown, MailDroid or others) which maintains its own account database and likely doesn't expose it.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文