【发布时间】:2013-03-20 16:33:00
【问题描述】:
我正在尝试使用 Google Play 服务生成的意图来选择 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);
}
}
对话框显示我的 google 帐户和创建新帐户的选项。
如果我选择“添加帐户”选项,我会正确重定向到帐户创建向导,但如果我选择现有帐户并单击“确定”,对话框将关闭但它永远不会返回到活动
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
【问题讨论】:
-
“永不返回活动”是什么意思?
onActivityResult会被调用吗? -
这正是我的意思。我试过调试和 Log.d,但它永远不会进入那里。
-
感谢您的关注,但像往常一样,这是一个愚蠢的错误,我花了好几个小时才找到。
标签: android google-play-services