Android 安卓谷歌&x2B;集成有时返回空值

Android 安卓谷歌&x2B;集成有时返回空值,android,google-plus,Android,Google Plus,在我的应用程序中,我使用Google Plus集成。还可以访问谷歌帐户详细信息,包括用户名、个人资料图像等。但这些用户详细信息有时返回空值。请帮我找出原因 这是我的代码: mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this) .addConnectionCallbacks(MainActivity.this) .addOnConnectionFailedL

在我的应用程序中,我使用Google Plus集成。还可以访问谷歌帐户详细信息,包括用户名、个人资料图像等。但这些用户详细信息有时返回空值。请帮我找出原因

这是我的代码:

mGoogleApiClient = new GoogleApiClient.Builder(MainActivity.this)
                .addConnectionCallbacks(MainActivity.this)
                .addOnConnectionFailedListener(MainActivity.this).addApi(Plus.API,Plus.PlusOptions.builder().build())
                .addScope(Plus.SCOPE_PLUS_LOGIN)
                .addScope(Plus.SCOPE_PLUS_PROFILE)
                .addApi(AppIndex.API).build();
在onConnected()中:

这里plusimage和plusname返回null。请帮助我查找原因。

添加此行

 Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
喜欢


更多信息。阅读

如果不向我们提供任何代码,将很难在您的代码中找到问题的来源。在提问之前,请先阅读这些文件。@jeffdill2抱歉,请提问Edited@krishna如果这个例子对你有用,请参考。。这也会返回nullvalue@krishna应用程序和google控制台之间的SHA1是否相同?//配置登录以请求用户ID、电子邮件地址和基本//配置文件。默认登录中包含ID和基本配置文件。GoogleSignenOptions gso=新建GoogleSignenOptions.Builder(GoogleSignenOptions.DEFAULT\u SIGN\u IN).requestEmail().build();然后//构建一个能够访问Google登录API和由gso指定的//选项的GoogleAppClient。mGoogleApiClient=new GoogleApiClient.Builder(this).enableautomanager(this/*FragmentActivity/,this/OnConnectionFailedListener*/).addApi(Auth.GOOGLE\u SIGN\u IN\u API,gso).build();谢谢大家…我不知道为什么,但是现在上面的代码工作得很好。
 Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
public void onConnected(Bundle connectionHint) {    

    Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);

    String personName="Unknown";
    if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
       Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
       String personName = currentPerson.getDisplayName();
       String personPhoto = currentPerson.getImage();
       String personGooglePlusProfile = currentPerson.getUrl();
    }
}