未读gmail邮件

public static final class LabelColumns { 
   
public static final String CANONICAL_NAME = "canonicalName"; 
   
public static final String NAME = "name"; 
   
public static final String NUM_CONVERSATIONS = "numConversations"; 
   
public static final String NUM_UNREAD_CONVERSATIONS = "numUnreadConversations"; 
} 
 
public void queryLabels(){ 
   
String account="[email protected]"; 
   
Uri LABELS_URI = Uri.parse("content://gmail-ls/labels/"); 
   
Uri ACCOUNT_URI = Uri.withAppendedPath(LABELS_URI, account); 
   
ContentResolver contentResolver=myActivity.getContentResolver(); 
   
Cursor cursor = contentResolver.query(ACCOUNT_URI, null, null, null, null); 
 
   
//iterate over all labels in the account 
   
if (cursor.moveToFirst()) { 
       
int unreadColumn = cursor.getColumnIndex(LabelColumns.NUM_UNREAD_CONVERSATIONS); 
       
int nameColumn = cursor.getColumnIndex(LabelColumns.NAME); 
       
do { 
           
String name = cursor.getString(nameColumn); 
           
String unread = cursor.getString(unreadColumn);//here's the value you need 
       
} while (cursor.moveToNext()); 
   
} 
} 
<uses-permission android:name="com.google.android.gm.permission.READ_GMAIL"/> 

你可能感兴趣的:(android,Google,Gmail)