我看到可以从PlusClient的loadPerson方法检索的Person对象有一个getCurrentLocation()方法。出于某种原因,我没有在线文档中看到getCurrentLocation()方法。此外,当我尝试使用它时,它总是返回null。这项功能有什么用?
答案 0 :(得分:1)
getCurrentLocation记录在Person对象下:
如果用户将其设置为Google+个人资料中的值,则会返回用户的当前位置。如果它们没有将值设置为值,它将返回null。
答案 1 :(得分:0)
所以我不想成为这个坏消息的承载者,但似乎Google+已停止支持他们的People api的getCurrentLocation部分。关于它的投诉,有一个完整的线程here。
编辑:找出问题的解决方法。我想他们只是将所有内容都放在了getplaceslived方法中。
String location = "";
for(PlacesLived place : Plus.PeopleApi.getCurrentPerson(mGoogleApiClient).getPlacesLived()){
//If the place is primary, record it and break
if(place.isPrimary()){
location = place.getValue();
break;
}
//If it isn't and there isn't any location yet, record the most recent location and wait to see if another is primary
if(location.equals("")){
location = place.getValue();
}
}