gpt4 book ai didi

android - 如何在 Android 中获取 Google+ 好友

转载 作者:太空宇宙 更新时间:2023-11-03 12:23:08 25 4
gpt4 key购买 nike

通过this example我能够将 Google+ 与 Android 集成,并获取我的信息,例如用户 ID、网址、个人资料名称和个人资料图片。
我还想获取我所有 friend 的列表并显示它。
我该怎么做,哪个类有用?

最佳答案

这可以使用 google plus api 来完成。虽然你不能在一个请求中得到每个 friend 的完整个人资料,但它至少会给你以下信息

  • 编号
  • 显示名称
  • 图片
  • 对象类型
  • 网址

要进一步获取个人资料信息,您必须分别获取每个 friend 的个人资料信息。

下面是获取好友列表的代码

       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”对象。

现在要获取更多个人资料信息,您可以使用以下代码 fragment

     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

关于android - 如何在 Android 中获取 Google+ 好友,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9584822/

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