How to get email received event in Android

∥☆過路亽.° 提交于 2019-12-12 02:55:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!