【问题标题】:Google+ PlusClient getCurrentLocation() methodGoogle+ PlusClient getCurrentLocation() 方法
【发布时间】:2013-05-25 20:03:34
【问题描述】:

我看到可以从 PlusClient 的 loadPerson 方法中检索到的 Person 对象有一个 getCurrentLocation() 方法。出于某种原因,我在在线文档中看不到 getCurrentLocation() 方法。此外,当我尝试使用它时,它总是返回 null。这个函数有什么用?

【问题讨论】:

  • 这是一个已知的错误。请参阅stackoverflow.com/questions/13742551/… 了解如何在 android 中获取当前位置
  • 瑞秋,跟我想的不太一样。我不想得到我自己的位置,我想得到我用 mPlusClient.loadPeople() 加载的其他人。

标签: android google-plus


【解决方案1】:

getCurrentLocation 记录在 Person 对象下:

http://developer.android.com/reference/com/google/android/gms/plus/model/people/Person.html#getCurrentLocation()

如果用户已将其设置为 Google+ 个人资料中的某个值,它会返回用户当前位置。如果他们没有将其设置为值,它将返回 null。

【讨论】:

  • 嘿,你确定吗?我有几个朋友和我一样设置了位置,但该方法总是返回 null 我猜它实际上还没有连接到任何东西。
  • 您是否已将您的位置设置为公开可见?仅当您将其公开时才会退还。
  • 不,谁会?它需要包含与经过身份验证的用户共享其位置的人的值。如果没有,那就没有意义了。
【解决方案2】:

所以我不想成为这个坏消息的承担者,但 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();
        }
    }

【讨论】:

    猜你喜欢
    • 2022-06-15
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 1970-01-01
    • 2013-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多