我正在尝试使用 Google Play Services 生成的意图来选择 google 帐户
private void showGoogleAccountPicker() {
Intent googlePicker = AccountPicker.newChooseAccountIntent(null, null,
new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE }, true, null, null, null, null);
startActivityForResult(googlePicker, PICK_ACCOUNT_REQUEST);
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if (requestCode == PICK_ACCOUNT_REQUEST && resultCode == RESULT_OK) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
Log.d(TAG, "Account Name=" + accountName);
}
}
该对话框显示我的谷歌帐户和创建新帐户的选项。
如果我选择“添加帐户”选项,我会正确重定向到帐户创建向导,但如果我选择现有帐户并单击“确定”,对话框将关闭但它永远不会返回到活动
Logcat 只打印这一行。我不认为这有什么关系。
W/IInputConnectionWrapper(23576): showStatusIcon on inactive InputConnection
来源
http://gmariotti.blogspot.com.es/2013/03/snippet-google-picker-account.html http://developer.android.com/reference/com/google/android/gms/common/AccountPicker.html