gpt4 book ai didi

Android/PlusClient :loadPeople returns incomplete PersonBuffer objects in onPeopleLoaded

转载 作者:行者123 更新时间:2023-11-30 03:24:25 26 4
gpt4 key购买 nike

我正在使用 Android/google_play_service 库和 PlusClient 做一些工作。具体来说,我只是在 ListView 中填入我的联系人姓名,以及他们的 G+ 个人资料页面上提供的一些基本信息。

为了加载列表,我进行如下操作:

// Create my PlusClient
activityContext = getActivity().getApplicationContext();
client = new PlusClient.Builder(activityContext, this, this)
.setScopes(Scopes.PLUS_PROFILE, Scopes.PLUS_LOGIN)
.build();

// Load the people
// this = the current activity
client.loadPeople(this, Person.Collection.VISIBLE);

// The below listener gets invoked when the list is loaded
... onPeopleLoaded(ConnectionResult cr, PersonBuffer pb, String nextPageToken) {
Person contact = null;

for (int i = 0; i < pb.getCount(); i++) {
contact = pb.get(i);

Log.d(TAG, contact.getDisplayName());
Log.d(TAG, contact.getAboutMe() == null ? "Null" : contact.getAboutMe());
Log.d(TAG, contact.getBirthday() == null ? "Null" : contact.getBirthday());
Log.d(TAG, contact.getEmails() == null ? "Null" : contact.getEmails().toString());
Log.d(TAG, contact.getCurrentLocation() == null ? "Null" : contact.getCurrentLocation());
Log.d(TAG, contact.getId() == null ? "Null" : contact.getId());
Log.d(TAG, contact.getLanguage() == null ? "Null" : contact.getLanguage());
Log.d(TAG, contact.getUrl() == null ? "Null" : contact.getUrl());
Log.d(TAG, contact.getName() == null ? "Null" : contact.getName().toString());
Log.d(TAG, contact.isPlusUser() ? "true" : "false");
Log.d(TAG, contact.isVerified() ? "true" : "false");
}
}

在上面的代码 fragment 中,唯一不返回 null 的方法是:- 获取显示名称- 获取ID- 获取网址

... 以及我所有的联系人(几百个)。在我的 onPeopleLoaded 方法中接收到的 PersonBuffer 中包含的 Person 对象似乎不完整。对于我的许多联系人,我在他们的 G+ 个人资料上看到的信息是可见的(他们正在与我分享)...

附带说明一下,我尝试了 API 资源管理器 ( https://developers.google.com/+/api/latest/people/get ),但我仍然获得了部分数据,但至少,以下 2 种方法在我的 android 应用程序不可用时似乎有效:- isPlusUser- 已验证

任何解释该行为的信息将不胜感激。

最佳答案

并非所有这些数据都应该对每个用户可用。只有用户设置为在其个人资料上公开的数据或对在授权对话框中明确授予的数据的访问权限。使用您指定的 PLUS_LOGIN 范围,您至少可以期望:基本个人资料数据(姓名、ID、照片、个人资料 URL)、年龄范围、语言和对应用程序。超出此范围的任何内容都必须由用户在其 Google+ 个人资料中明确公开。

如果您需要在使用 getter 之前检查数据是否存在,也可以使用“has”方法。参见 com.google.android.gms.plus.model.people.Person对于所有的配置文件方法。

关于Android/PlusClient :loadPeople returns incomplete PersonBuffer objects in onPeopleLoaded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18501447/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com