Ron*_*hta 3 android google-plus
通过这个例子,我可以将Google+与Android集成,并获取我的信息,如用户ID,网址,个人资料名称和个人资料图片.
我还要获取所有朋友的列表并显示它.
我该怎么做以及哪个类有用?
小智 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
}
Run Code Online (Sandbox Code Playgroud)
回调中的"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.
Run Code Online (Sandbox Code Playgroud)
为了进一步说明,请查看此链接 https://developers.google.com/+/mobile/android/people
归档时间: |
|
查看次数: |
6361 次 |
最近记录: |