Get User Name from Google Plus in android

前端 未结 5 2018
迷失自我
迷失自我 2021-01-17 16:11

I have integrated Google plus with my android app. Everything is working fine, i am also connected to Google plus but I am not able to get the name of current user logged.

5条回答
  •  轮回少年
    2021-01-17 16:50

    In my case the null returned because I have added that line:

    addScope(new Scope(Scopes.EMAIL))

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API)
                .addScope(new Scope(Scopes.PROFILE))
                //.addScope(new Scope(Scopes.EMAIL))
                .build();
    

    ================= UPDATE ======================== Scopes should be set as below:

    mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API)
                .addScope(Plus.SCOPE_PLUS_PROFILE)
                .addScope(Plus.SCOPE_PLUS_LOGIN)
                .build();
    

提交回复
热议问题