【发布时间】:2015-07-03 22:31:59
【问题描述】:
即使我已经登录并且我的应用程序已经连接到帐户,Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) 行也会返回 null。
这是我的代码:
@Override
public void onConnected(Bundle connectionHint) {
mSignInClicked = false;
Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
String personName = "No one!";
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
personName = currentPerson.getDisplayName();
String personGooglePlusProfile = currentPerson.getUrl();
Toast.makeText(this, "Welcome " + personName, Toast.LENGTH_LONG).show();
}
}
Log cat 还显示: 请求可见圈子时出错:Status{statusCode=NETWORK_ERROR, resolution = null}
【问题讨论】:
-
发布您的错误日志。
-
这可能是由于包名。你的包名是什么,你放入开发者控制台的包名是什么?
-
我的包名没问题,我已经登录@MurtazaKhursheedHussain
-
“没有人”是有效用户吗?
-
“没有人!”仅分配给 personName 以通知我它是否真的获得了用户的显示名称。真正的问题是它没有进入 if 语句,因为 Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) 为空。 @MurtazaKhursheedHussain
标签: android oauth-2.0 google-plus