Nou*_*tti 5 android google-plus
我能够使用google plus登录并获取我谷歌加圈子中所有人的列表但现在我还想获得我圈子中所有人的电子邮件地址是否有办法做到这一点?我尝试过这段代码,但它不起作用.
public void onPeopleLoaded(ConnectionResult status, final PersonBuffer personBuffer,
String nextPageToken)
{
if (status.getErrorCode() == ConnectionResult.SUCCESS)
{
try
{
//Add all friends ids in an arraylist
int count = personBuffer.getCount();
//Loop through all the ids of google plus friends
for (int i = 0; i < count; i++)
{
//mListItems.add(personBuffer.get(i).getDisplayName());
//mListIds.add(personBuffer.get(i).getId());
friends_gplus_Ids += personBuffer.get(i).getId() + ",";
//Log.d("Emails", personBuffer.get(i).getOrganizations().toString());
//personBuffer.get(i).getEmails().size();
if((personBuffer.get(i).getEmails().size() > 0))
{
Log.d("Emails", personBuffer.get(i).getEmails().get(0).toString());
}
else
{
Log.d("Emails", "Null");
}
}
}
finally
{
personBuffer.close();
}
}
Run Code Online (Sandbox Code Playgroud)
您可能需要请求 Google+ 范围和Contacts API范围 ( https://www.google.com/m8/feeds)。然后,您需要请求用户的联系人并查找具有Google+ 个人资料 URL 的联系人,如下所示:
<gContact:website href='http://www.google.com/profiles/1234567890' rel='profile'/>
Run Code Online (Sandbox Code Playgroud)
然后,您将查看该联系人的电子邮件地址是否也存在作为同级元素。