问题
Is there a way to listen for incoming/outgoing email messages or access the inbox directly?
I read that since there is no default mail client in the Android SDK it is not possible unless the client used on the phone implements some custom mechanisms. Is this still the case?
回答1:
Emails are not part of the Android OS so you cannot code a global Broadcast Receiver (like you would for incoming SMS). The obvious workaround is to code Broadcast Receivers for the top X most popular email clients on Android OS which do broadcast incoming emails.
K9 does give you the flexibility of registering Broadcast Receivers for incoming emails - see https://github.com/k9mail/k-9/wiki/Intents.
Gmail does not have any official / documented API for receiving info about incoming emails. But until a while back, you could make use of Content Observers for monitoring changes to Gmail. I believe this no longer works though.
I think the real issue here is privacy and security. Emails contain much more info compared to SMS. As a user, you really would not want an app ecosystem where third party apps can start monitoring your personal and professional emails.
来源:https://stackoverflow.com/questions/10633698/how-to-listen-for-email-messages