问题
I could not find a way to listen email received event. Can any one please suggest me on this.
your valuable suggestions are highly appreciated.
回答1:
The answer is no. 3rd party apps can't access the stock Email applications data.
回答2:
I could succeed upto an extent, Now I could receive events for any changes happening in gmail account but still i am not clear about how to find only incoming mails.
Note: I got some hacking techniques for getting this done but it will not work starting from froyo release.
currently I am using below code: onChange method will get invoked for any changes happening in gmail.
mContext.getContentResolver().registerContentObserver(Uri.parse("content://gmail-ls/unread"), false, GmailObserver(new Handler() {}));
class GmailObserver extends ContentObserver {
public GmailObserver(Handler handler) {
super(handler);
}
@Override
public boolean deliverSelfNotifications() {
System.out.println("@@@ ContentObserver deliverSelfNotifications");
return super.deliverSelfNotifications();
}
@Override
public void onChange(boolean selfChange) {
System.out.println("@@@ ContentObserver onChange");
super.onChange(selfChange);
}
}
来源:https://stackoverflow.com/questions/9552768/how-to-get-email-received-event-in-android