26

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.

LordSidious
  • 508
  • 5
  • 15
  • Did you try to use, locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); It will use your GPS (if inbuilt in Android Device) and you can get the Latitude, Longitude. Save Latitude & Longitude of Home & work. Whenever you get a onLocationChanged, do your relevant work. – surender8388 Apr 23 '13 at 19:18
  • yeah. i know i can do this. but u see. the idea is not to use gps location for 3 reasons. 1. I dont want a battery hungry app 2. I dont want to ask the user things like Is this your home? 3. If i dont want to ask him that i will need a complicated algorithm that discover by himself where is the home and the work depending on how much time dos this guys spends in every place. I want to know if i can use the "Already" calculated locations by google for your home and work (Like the do in google now). – LordSidious May 17 '13 at 12:09
  • I don't have any idea about algo google uses, but I think you can have some logic on based on time. I means if its night time most probably its home, something like that. – surender8388 May 18 '13 at 15:11

5 Answers5

5

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: home_detection

Dus
  • 4,052
  • 5
  • 30
  • 49
1

You could detect Wifis and assign them to a place (Home/Work)

(I have never tried anything like this but this might help: http://developer.android.com/reference/android/net/wifi/WifiManager.html#startScan(), http://developer.android.com/reference/android/net/wifi/WifiManager.html#getScanResults())

Damian Jäger
  • 204
  • 2
  • 12
1

I don't think you can get the information from Google APIs. As @surender8388 mentions in the comments, the only way to make it out is using location and time.

ACCESS_COARSE_LOCATION is a good choice if you don't want to use GPS.

ThomasYe
  • 36
  • 4
0

Well Google Now is using a complex algorithm as does Waze. You will also notice that Google Now will ask you if a location is important after a while. Its looking at places where the user spends a lot of time frequently. One of those will certainly be home and the other will certainly be work. Just ask for cheap location in 4.2 and see where the user trends.

AfroRick
  • 610
  • 5
  • 17
0

What makes Google Now is to save the time and number of times you visit a place with the hours in the same place and wireless networks. From these data, when they reached a certain certainty, asks the user if wants to assign it as the home/work.

FireZenk
  • 1,056
  • 1
  • 16
  • 28