Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用Auth.GoogleSignInApi.getsigninent的Google登录帐户类型_Android_Google Signin_Android Account - Fatal编程技术网

Android 使用Auth.GoogleSignInApi.getsigninent的Google登录帐户类型

Android 使用Auth.GoogleSignInApi.getsigninent的Google登录帐户类型,android,google-signin,android-account,Android,Google Signin,Android Account,我遇到了两种创建Google登录意图的方法: 一, 二, 使用第一种方法,我可以获得用户的帐户图片:urithumbnailurl=acct.getPhotoUrl() 使用第二种方法,我可以获得用户的帐户类型:String mType=data.getStringExtra(AccountManager.KEY\u account\u type) 我需要帐户类型来获取访问令牌: Account account = new Account(mEmail, mType); token = Goog

我遇到了两种创建Google登录意图的方法:

一,

二,

使用第一种方法,我可以获得用户的帐户图片:urithumbnailurl=acct.getPhotoUrl()

使用第二种方法,我可以获得用户的帐户类型:String mType=data.getStringExtra(AccountManager.KEY\u account\u type)

我需要帐户类型来获取访问令牌:

Account account = new Account(mEmail, mType);
token = GoogleAuthUtil.getToken(SignInActivity.this, account, mScope);
我一直在为mType(“com.google”)传递一个硬编码变量,该变量可以工作,但感觉不合适。在使用intent的Auth.GoogleSignInApi.getsigninent版本时,是否有办法获取帐户类型

另外,在使用AccountPicker.NewChooseAccountContent版本的intent时,是否有方法获取帐户图片

private void signIn() {
    Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"},
            false, null, null, null, null);
    startActivityForResult(intent, RC_SIGN_IN);
}

@Override
protected void onActivityResult(final int requestCode, final int resultCode,
                                final Intent data) {
    if (requestCode == RC_SIGN_IN && resultCode == RESULT_OK) {
        String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
        Log.d(TAG, "onActivityResult: " + accountName);
        String mEmail = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
        String mType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
        Log.d(TAG, "onActivityResult: " + mType);
    }
}
Account account = new Account(mEmail, mType);
token = GoogleAuthUtil.getToken(SignInActivity.this, account, mScope);