代码之家  ›  专栏  ›  技术社区  ›  Sanath

如何在我的Glassware中获取谷歌眼镜位置更改通知

  •  3
  • Sanath  · 技术社区  · 12 年前

    你能指导我怎么做吗。我必须习惯位置的变化,并且必须根据该位置发送一些信息。

    2 回复  |  直到 12 年前
        1
  •  4
  •   Prisoner    12 年前

    看见 https://developers.google.com/glass/location https://developers.google.com/glass/v1/reference/locations 有关使用谷歌眼镜定位的完整信息。

    请记住,您需要申请额外的范围 https://www.googleapis.com/auth/glass.location 以便获得任何位置信息。

    一旦你完成了这项工作,Glass会将最近已知的位置(通常是你在过去10分钟内去过的地方)附加到向你报告的任何时间线项目上。

    您可以随时从Glass获得可用的位置更新列表,或“最新”位置。此外,您还可以订阅“locations”集合(请参阅 https://developers.google.com/glass/v1/reference/subscriptions )您将大约每10分钟收到一次位置更改通知,其中包括获取相关位置的ID。

        2
  •  0
  •   Sanath    12 年前

    当用户订阅我们的Glassware应用程序时,我们可以插入位置更改订阅。之后,镜像API将通知对给定url的位置更改。

    这样地

                //create a Subscription for location changes
                Subscription subscriptionLocation = new Subscription()
                {
                    Collection = "locations",
                    UserToken = userId,
                    CallbackUrl = Url.Action("Notify", "Notify", null, Request.Url.Scheme)
                };
                //insert a Subscription
                mirrorService.Subscriptions.Insert(subscriptionLocation).Fetch();