获取用户名来自谷歌加在机器人 [英] Get User Name from Google Plus in android
本文介绍了获取用户名来自谷歌加在机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经将谷歌,加上我的Android应用程序。一切工作正常,我也连接到谷歌加,但我不能够获得当前登录用户的名称。
I have integrated Google plus with my android app. Everything is working fine, i am also connected to Google plus but I am not able to get the name of current user logged.
public void onConnected(Bundle connectionHint) {
String personName="Unknown";
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
personName = currentPerson.getDisplayName();
}
}
Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)
此方法始终返回空
任何帮助将AP preciated。 谢谢。
Any help will appreciated. Thanks.
推荐答案
您必须加入这一行:
Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
这样的:
public void onConnected(Bundle connectionHint) {
/* This Line is the key */
Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
String personName="Unknown";
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
personName = currentPerson.getDisplayName();
.........
}
}
这篇关于获取用户名来自谷歌加在机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文