【问题标题】:AccountPicker.newChooseAccountIntent, Dialog closes when account selectedAccountPicker.newChooseAccountIntent,选择帐户时对话框关闭
【发布时间】: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


【解决方案1】:

事实证明我的 Activity 不在 Back Stack 中,因为我在 Manifest 中明确请求它

<activity
            android:name=".ui.LoginActivity"
            android:label="@string/app_name"
            android:noHistory="true"

所以对话框找不到任何人来返回结果。

真是浪费时间:(

【讨论】:

  • 我也遇到了这样的问题,原因是清单中的 android:launchMode="singleInstance"
猜你喜欢
  • 1970-01-01
  • 2023-03-14
  • 2011-04-05
  • 2012-08-01
  • 2017-02-09
  • 2014-12-01
  • 2011-03-22
  • 2017-01-08
  • 1970-01-01
相关资源
最近更新 更多