mGoogleApiClient.isConnected()始终为false

时间:2017-04-28 07:47:54

标签: android google-login

我想检查用户是否使用Google登录,但为什么mGoogleApiClient.isConnected的值总是 false ?我联系了onStart

在onStart

@Override
protected void onStart() {
    super.onStart();
    mGoogleApiClient.connect();
}

的onCreate

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addApi(Plus.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

检查谷歌登录的条件

Log.i("TAG", "onCreate: google apiclient --> "+mGoogleApiClient);
    Log.i("TAG", "onCreate: google apiclient --> "+mGoogleApiClient.isConnected());

    if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
        showSocialUserDetail("google");
    } else {
        Log.i("TAG", "onCreate: google not login");
    }

log

0 个答案:

没有答案