通过this example我可以将Google+与Android集成,并获取用户ID,网址,个人资料名称和个人资料图片等信息。
我还想获取所有朋友的名单并进行展示
我该怎么做以及哪个类有用?
答案 0 :(得分:6)
这可以使用google plus api完成。虽然您无法在一个请求中获得每位朋友的完整个人资料信息,但它至少会为您提供以下信息
要进一步获取个人资料信息,您必须单独获取每位朋友的个人资料信息。
以下是获取朋友列表的代码
mPlusClient.loadPeople(new OnPeopleLoadedListener()
{
@Override
public void onPeopleLoaded(ConnectionResult status, PersonBuffer personBuffer, String nextPageToken)
{
if ( ConnectionResult.SUCCESS == status.getErrorCode() )
{
Log.v(TAG, "Fetched the list of friends");
for ( Person p : personBuffer )
{
Log.v(TAG, p.getDisplayName());
}
}
}
}, Person.Collection.VISIBLE); // VISIBLE=0
}
回调中的“for-loop”是迭代每个“Person”对象。
现在要获取更多个人资料信息,您可以使用以下代码片段
mPlusClient.loadPerson(new OnPersonLoadedListener()
{
@Override
public void onPersonLoaded(ConnectionResult status, Person person)
{
if ( ConnectionResult.SUCCESS == status.getErrorCode())
{
Log.v(TAG, person.toString());
}
}
}, "me"); // Instead of "me" use id of the user whose profile information you are willing to get.
为了进一步说明,请查看此链接 https://developers.google.com/+/mobile/android/people
答案 1 :(得分:1)
目前没有向G +用户的列表朋友公开API方法。
您可以详细了解此处公开的方法:https://developers.google.com/+/api/