如何获取设备中存储的用户自己的电子邮件地址?
我需要检索存储在设备中的用户的所有电子邮件地址(不是他朋友的电子邮件地址,而是他自己的电子邮件地址)。 例如,如果我有三个邮件地址 [电子邮件受保护],< 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些地址大部分由电子邮件客户端维护,没有内容提供商可以获取这些地址。
如果您的目标是使用地址列表来选择外发电子邮件的返回地址,那么这不符合 Android 的处理方式。您的应用程序应该通过抛出正确配置的
ACTION_SEND
意图来声明它想要发送电子邮件。无论应用程序最终提供什么服务,它都可以让用户选择在发送时使用哪个帐户和返回地址。附录:
默认电子邮件客户端有一个名为
content://com.android.email.provider/account
的内容提供程序,您不应该或不能使用它,因为:com.android.email.permission.ACCESS_PROVIDER
权限。protectionLevel
为signatureOrSystem
,它限制对存储在系统映像中或使用与系统映像中相同密钥签名的应用程序的授权。您的应用程序不太可能属于这些类别中的任何一个。其他需要注意的事项:
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:com.android.email.permission.ACCESS_PROVIDER
permission.protectionLevel
ofsignatureOrSystem
, 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: