我使用此功能选择帐户并选择获取用户的电子邮件。
private void pickUserAccount() {
String[] accountTypes = new String[]{"com.google"};
try { // request account
Intent intent = AccountPicker
.newChooseAccountIntent(null, null, accountTypes, false, null, null, null, null);
startActivityForResult(intent, AuthProcess.REQUEST_CODE_PICK_ACCOUNT);
/*
Error control
*/
} catch (CriticalException e) {
throw e;
} catch (OutOfMemoryError e) { // problems with memory
throw e;
} catch (Throwable e) { // Other exceptions
final String message = "Error during google account picker dialog: " + e;
throw new CriticalException(logcat, message);
}
} // End: pickUserAccount
在Android 6.0中,此代码打开了所选帐户的对话框,尽管该设备上只有一个Google帐户。在android 4.4.2中,它工作得很好。问题是什么?谢谢。