这是获取Gmail帐户标签信息的方法:http://android-developers.blogspot.ca/2012/04/gmail-public-labels-api.html
最近,谷歌宣布推出具有交换功能的Gmail 5.0。我们如何看到交易账户的标签信息?
对于getAccountsByTypeAndFeatures()方法,我必须将ACCOUNT_TYPE_GOOGLE更改为ACCOUNT_TYPE_EXCHANGE并使用feature = null才能获得交换帐户。
private static final String ACCOUNT_TYPE_GOOGLE = "com.google";
private static final String ACCOUNT_TYPE_IMAP = "com.google.android.gm.legacyimap";
private static final String ACCOUNT_TYPE_EXCHANGE = "com.google.android.gm.exchange";
AccountManager.get(this).getAccountsByTypeAndFeatures(ACCOUNT_TYPE_EXCHANGE, null,
new AccountManagerCallback<Account[]>() {
@Override
public void run(AccountManagerFuture<Account[]> future) {
Account[] accounts = null;
try {
accounts = future.getResult();
} catch (Exception e) {
Log.e(TAG, "Got OperationCanceledException", e);
}
}
}, null /* handler */);
获取帐户[]信息后,获取标签信息的代码如下:
final Bundle args = new Bundle();
args.putString("account", sAccount);
getSupportLoaderManager().restartLoader(0, args, this);
以下是获取标签信息的代码:
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (data != null) {
data.moveToFirst();
String name = data.getString(data.getColumnIndex(GmailContract.Labels.NAME));
String unread = data.getString(data.getColumnIndex(GmailContract.Labels.NUM_UNREAD_CONVERSATIONS));
String total = data.getString(data.getColumnIndex(GmailContract.Labels.NUM_CONVERSATIONS));
String uri = data.getString(data.getColumnIndex(GmailContract.Labels.URI));
}
}
对于Gmail帐户,我会收到标签信息(姓名,未读,总计,uri等)。但是,对于交换账户,我不会收到任何信息。 有办法吗?