在 Android 中获取来自 Gmail 的邮件列表
有这样的问题:我需要从我的 Gmail 帐户获取邮件列表。它如下面的代码片段所示:
Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
File file = new File("content://gmail-ls/messages/"+accounts[0].name+"/");
if(file.exists())
{
Uri uri = Uri.parse("content://gmail-ls/messages"+accounts[0].name+"/");
cursor = this.getContentResolver().query(uri, null, null, null, null);
}
但它不会进入“if”条件,因为这样的路径不存在。如果没有“if”条件,当我通过 Uri 的查询将游标分配给 gmail-ls 时,它会抛出异常。 有谁知道这个问题如何解决?将不胜感激任何建议!
Have such kind of problem: I need to get list of mails form my gmail account. It`s shown in snippet below:
Account[] accounts = AccountManager.get(this).getAccountsByType("com.google");
File file = new File("content://gmail-ls/messages/"+accounts[0].name+"/");
if(file.exists())
{
Uri uri = Uri.parse("content://gmail-ls/messages"+accounts[0].name+"/");
cursor = this.getContentResolver().query(uri, null, null, null, null);
}
But it doesn't enter in "if" condition as such path does not exist. With out "if" condition it throws with exception on moment when I assign a cursor by a query with Uri to gmail-ls.
Anyone knows how this problem can be solved? Will appreciate any advice!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第三方应用程序似乎无法再从 Gmail 读取电子邮件
参考 http://productforums.google.com/forum/#!msg/ gmail/XD0C4sw9K7U/LpNXxFNnfgc
Looks like it is not possible any more for third-party apps to read email from Gmail
ref http://productforums.google.com/forum/#!msg/gmail/XD0C4sw9K7U/LpNXxFNnfgc