问题描述
基本上,我想让我的应用程序读取
你能告诉我有没有办法这样做?
您需要注册一个内容观察者(不是广播接收者)
contentResolver.registerContentObserver Uri.parse(content:// gmail-ls),true,gmailObserver);
gmailObserver
是您自己的ContentObserver对象。 / p>
ContentObserver.onChange
将每次在Gmail中发生变化时被调用。
您可以在此处获取所有对话:
游标对话= _contentResolver.query(Uri.parse(content: // gmail-ls / conversations /+ YourEmailAddress),null,null,null,null);
实际的会话消息将是:
游标消息= _contentResolver.query(Uri.parse(content:// gmail-ls / conversations /+ YourEmailAddress +/+ String.valueOf(conversationId)+/消息),null,null,null,null);
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
is your own ContentObserver object.
ContentObserver.onChange
is going to be called every time something changes in Gmail.Here you get all conversations like so:
Cursor conversations = _contentResolver.query(Uri.parse("content://gmail-ls/conversations/" + YourEmailAddress), null, null, null, null);
And the actual conversation messages will be:
Cursor messages = _contentResolver.query(Uri.parse("content://gmail-ls/conversations/" + YourEmailAddress + "/" + String.valueOf(conversationId) + "/messages"), null, null, null, null);
这篇关于如何检测我在Android设备上收到的电子邮件/ Gmail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!