如何检测,我收到一封电子邮件/ Gmail的在我的Andr​​oid设备? [英] How to detect that i have received an email/gmail on my Android Device?

查看:115
本文介绍了如何检测,我收到一封电子邮件/ Gmail的在我的Andr​​oid设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来检测或事件时,我收到一个Gmail /电子邮件我的Andr​​oid设备上被触发。

Is there a way to detect or an event being triggered when i receive a gmail/email on my android device.

基本上,我想我的应用程序,当我收到它来阅读电子邮件通知。

Basically i would like my application to read the email notification when i receive it.

能否请你告诉我,如果有办法做到这一点?

Could you kindly tell me if there is way to do this ?

推荐答案

您需要注册内容观察者(不是广播接收器)

You need to register a content observer (not broadcast receiver)

contentResolver.registerContentObserver(Uri.parse("content://gmail-ls"), true, gmailObserver); 

gmailObserver 是你自己的ContentObserver对象。

gmailObserver is your own ContentObserver object.

ContentObserver.onChange 将被称为每次改变的东西在Gmail中。 在这里,你会得到所有的对话,像这样:

ContentObserver.onChange is going to be called every time something changes in Gmail. Here you get all conversations like so:

Cursor conversations = _contetResolver.query(Uri.parse("content://gmail-ls/conversations/" + YourEmailAddress, null, null, null, null); 

和实际通话的消息将是:

And the actual conversation messages will be:

Cursor messages = _contetResolver.query(Uri.parse("content://gmail-ls/conversations/" + YourEmailAddress + "/" + String.valueOf(conversationId) + "/messages"), null, null, null, null); 

这篇关于如何检测,我收到一封电子邮件/ Gmail的在我的Andr​​oid设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆