如何在 Android 中为用户获取用户的家庭/工作位置 [英] How to get the user Home/Work location for a user in Android

查看:40
本文介绍了如何在 Android 中为用户获取用户的家庭/工作位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,可为用户提供信息"项目的快速列​​表,但我想设置一个选项,以便他在离开家或工作时收到这些项目作为通知.

我注意到(现在在我的设备上使用谷歌)他们可以告诉用户住在哪里和工作在哪里,这样他们就可以在你离开或到达其中一个地方时向你推送通知(如果这样的话).

有什么方法可以获得 Google Now(它们来自谷歌地图)用于此的坐标(纬度和经度)吗?.我的意思是类似(GoogleMapsApi > GetFavorite Locations > Get Home Location > Get坐标 > 在我的应用中使用它们).

如果有的话,你能告诉我一个例子、教程或代码吗?

提前致谢.

解决方案

您可以使用名为

Im developing an app that brings the user a quick list of "info" items but i want to set an options so that he receives this items as notifications when he is leaving home or work.

I noticed (using google now on my device) that they can tell where the user lives and works so that they can push you notifications whenever you leave or arrive at one of this places (a sort of if this then that).

Is there any way yo obtain the coordinates (lat and long) that Google Now (they come from google maps) uses for this?. I mean something like (GoogleMapsApi > GetFavorite Locations > Get Home Location > Get coordinates > use them in my app).

If there is, can you point me to an example, tutorial, or code that does this.

Thanks in Advance.

解决方案

You can use a free sdk called Neura, which has a learning phase for detecting your significant places such as home, work, gym, grocery store, restaurants, etc.

Plus, and a big plus - it can notify your application when your user arrives/leaves specific place you define in advanced.

This suits your needs exactly, for this example, let's talk about home :

  1. Finding your home :
    • The Neura sdk detects your home within few days, since the system needs to learn your habits and whereabouts. So, when you're sleeping at a place for few days, hanging out there as well, interact with devices at a place -> there's a solid indication that this place is your home.
    • If you don't want to wait few days, you can also display a dialog to your user to tell him to set his home, which is NOT so much intelligent, i have to admit, but with this sdk you can show your user a picker asking him to select his home.
  2. You can request that Neura will notify to your user (via Google Cloud Messaging) when he arrived home for example.
  3. Display your list of infos when you receive a push for 'userArrivedHome'.

You can check out this project on git, doing exactly as i described, for :

  1. Find your user home address
  2. Mute/unmute the phone when user arrives/leaves work respectively.
  3. Receiving an event when user arrives/leaves home.

Feel free to take these projects and do as you please with it.

For finding your user home address project, here's the outcome of the application:

这篇关于如何在 Android 中为用户获取用户的家庭/工作位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆