我在我的应用程序中使用 Google+ 进行用户登录和在用户墙上发帖。
在用户墙上发帖效果很好。
但是当我尝试获取用户个人资料数据时,它会将用户生日年份返回为 0000。这只发生在某些用户和其他用户身上,我得到了正确的生日。
我有以下代码来初始化 Google+ 客户端
mPlusClient = new PlusClient.Builder(getApplicationContext(), this, this)
.setVisibleActivities("http://schemas.google.com/AddActivity").setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE).build();
我有以下代码来检索用户个人资料数据:
mPlusClient.loadPerson(this, "me");
@Override
public void onPersonLoaded(ConnectionResult arg0, Person arg1)
{
Log.i("Person",""+arg1.toString());
if (currentperson.hasBirthday())
{
String Birthday = currentperson.getBirthday();
MyLog.i("Birthdate :", "" + Birthday);
}
}
为什么会这样? 为什么它只发生在某些用户身上? 我错过了什么吗?
请帮帮我。
最佳答案
用户可以在他们的个人资料设置中决定他们是否要公开他们的生日(这是您唯一会得到的生日)以及他们是否要包括年份的附加设置。禁用此设置后,您将获得 0000
作为年份而不是实际年份。
关于android Google+ 将用户生日年份返回为 0000,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17783971/