我想获得一个int,其中包含设备帐户中未读电子邮件的数量。我已经看到有一种新方法可以使用" Gmail标签公共API"
http://android-developers.blogspot.in/2012/04/gmail-public-labels-api.html
我已阅读文档并下载了示例应用程序,它确实有效。但我有两个问题:(
我的目的是获得一个未读会话数量的int,我试试这个:
public static int getUnreadGmailCount(Context context) {
ContentResolver cr = context.getContentResolver();
Cursor cursor = cr.query(GmailContract.Labels.getLabelsUri("ensisinfo102@gmail.com"),
null,
null, null,
null);
if (cursor == null || cursor.isAfterLast()) {
Log.d(TAG, "No Gmail inbox information found for account.");
if (cursor != null) {
cursor.close();
}
return 0;
}
int count = 0;
while (cursor.moveToNext()) {
if (CANONICAL_NAME_INBOX_CATEGORY_PRIMARY.equals(cursor.getString(cursor.getColumnIndex(CANONICAL_NAME)))) {
count = cursor.getInt(cursor.getColumnIndex(NUM_UNREAD_CONVERSATIONS));
System.out.println("count is====>"+count);
break;
}
}
cursor.close();
return count;
}
但不起作用,总是返回" 0",但在gmail中我有3条未读消息
非常感谢任何帮助
感谢和问候
答案 0 :(得分:0)
您可以get a label并查看<div class="container">
<div class="tooltip">Shorter text
<span class="tooltiptext">A short tooltip.</span>
</div>
</div>
<div class="container">
<div class="tooltip">Longer text
<span class="tooltiptext">When I try to make it work with longer text in the tooltip, I can't make it look good. Either I have to specify a fixed width or min-width for the tooltip, which makes it look decent for longer texts but awful for short ones, or I don't, and the longer text only expands vertically, assuming the lowest possible width without overflow.
<br />
<br />
Also, the positioning doesn't work well with tooltips spanning multiple lines.</span>
</div>
</div>
。 messagesUnread
标签可能是您想要的:
请求强>
INBOX
<强>响应强>
GET https://www.googleapis.com/gmail/v1/users/me/labels/INBOX?access_token={ACCESS_TOKEN}
答案 1 :(得分:0)