再次是我
这次我正在尝试获取gmail的未读电子邮件号码并将其显示在屏幕上。
我正在关注Gmail公共标签API并获取此代码
protected int getGmail(Context context) {
AccountManager.get(context).getAccountsByTypeAndFeatures(ACCOUNT_TYPE_GOOGLE, FEATURES_MAIL,
new AccountManagerCallback() {
@Override
public void run(AccountManagerFuture future) {
Account[] accounts = null;
try {
accounts = future.getResult();//error here
if (accounts != null && accounts.length > 0) {
String selectedAccount = accounts[0].name;
queryLabels(selectedAccount);
}
} catch (OperationCanceledException oce) {
// TODO: handle exception
} catch (IOException ioe) {
// TODO: handle exception
} catch (AuthenticatorException ae) {
// TODO: handle exception
}
}
}, null /* handler */);
出现此错误:无法从Object转换为Account []
问题是:在获得结果的同时,我需要做些什么来消除此错误?