【发布时间】:2023-03-25 06:58:01
【问题描述】:
我已将 Google plus 与我的 Android 应用程序集成。一切正常,我也连接到 Google plus,但我无法获取当前用户的登录名称。
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)这个方法总是返回null。
任何帮助将不胜感激。 谢谢。
【问题讨论】:
-
String personGooglePlusProfile = currentPerson.getUrl();添加这一行
-
您是否在
if (Plus....)语句中缺少}? -
} 在此处粘贴代码时缺少此括号。
-
@Anjali,感谢您的回复。当我将 currentPerson 设为 null 时,我无法调用 getUrl。它会给出空指针异常。
标签: android google-api google-plus