开发者

How to get user own email addresses stored in the device?

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 geltrude@gmail.com, geltry@yahoo.co.uk and cippalippa@hotmail.com, i'm looking for a method that returns an array (or similar) with these three Strings: ["geltrude@gmail.com", "geltry@yahoo.co.uk", "cippalippa@hotmail.com"]. 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 开发者_如何学Pythonthe gmail client app (that are the default used apps, I think). Thanks in advance. G.


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜