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还显示: 请求可见圈时出错:状态{statusCode = NETWORK_ERROR,resolution = null}
答案 0 :(得分:1)
您需要在Google Developer Console中启用Google+ API。