通过圈子中的谷歌加联系人获取生日

时间:2015-12-05 07:53:01

标签: android google-plus google-play-services google-signin google-plus-signin

我试图通过无法检索此类信息来获取所有联系人的生日以及我自己的生日。其他所有工作,我可以获取我的圈子中的名称,ID,图片和联系人,以及我自己的,但生日似乎是空的。 甚至在我的生日公开之后,联系人的生日也是公开的。

获取我的详细信息

if (Plus.PeopleApi.getCurrentPerson(mgoogleApiClient) != null) {
            Person currentPerson = Plus.PeopleApi.getCurrentPerson(mgoogleApiClient);
            String personName = currentPerson.getDisplayName();
            String personPhotoUrl = currentPerson.getImage().getUrl();
            String personGooglePlusProfile = currentPerson.getUrl();
            String email = Plus.AccountApi.getAccountName(mgoogleApiClient);

            Log.e("details", "Name: " + personName + ", plusProfile: "
                    + personGooglePlusProfile + ", email: " + email
                    + ", Image: " + personPhotoUrl + "   ID:" + currentPerson.getId()
                    + "  bday" + currentPerson.getBirthday());
        } 

获取朋友列表详细信息

Plus.PeopleApi.loadVisible(mgoogleApiClient, null).setResultCallback(new ResultCallback<People.LoadPeopleResult>() {
            @Override
            public void onResult(People.LoadPeopleResult loadPeopleResult) {
                if (loadPeopleResult.getStatus().getStatusCode() == CommonStatusCodes.SUCCESS) {
                    PersonBuffer personBuffer = loadPeopleResult.getPersonBuffer();
                    try {
                        int count = personBuffer.getCount();
                        for (int i = 0; i < count; i++) {
                            Log.i("person", "Person " + i + " name: " + personBuffer.get(i).getDisplayName() + " - id: " + personBuffer.get(i).getId());
                            Log.i("birthday", personBuffer.get(i).getBirthday() + "" + "  hasBday" + personBuffer.get(i).hasBirthday());
                        }
                    } finally {
                        personBuffer.close();
                    }
                } else {
                    Log.i("error", "Error");
                }
            }
        });

1 个答案:

答案 0 :(得分:0)

恕我直言,转到Google's documentation,你会发现:

  

公共摘要PendingResult loadVisible   (GoogleApiClient googleApiClient,String pageToken)

     

加载用户圈子中的可见人员列表。更多   信息,见:   https://developers.google.com/+/api/latest/people/list

     

每个人都将包含 id,displayName,image,objectType和   已填充网址字段。要检索其他个人资料数据,请使用   加载(GoogleApiClient,String ...)方法。

所以,尝试使用

load(GoogleApiClient, String...)

希望这有帮助!