如何在Android中获取google plus圈子的电子邮件地址?

时间:2015-10-12 05:28:43

标签: android google-plus

我可以获取google plus登录用户的电子邮件地址

  String emailuser = Plus.AccountApi.getAccountName(mGoogleApiClient);

我还可以使用

获取google plus圈子的详细信息
Plus.PeopleApi.loadVisible(mGoogleApiClient,null).setResultCallback(this);

但是如何检索android中的google plus圈子电子邮件地址?

1 个答案:

答案 0 :(得分:0)

试试这个

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(); 
            }
}