8

I'm using intents to launch Google Navigation:

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + location)); 
startActivity(i);

location is a string with GPS coordinates.

Google Navigation pops up nicely and plots the route. Can they return some type of callback when the user has reached their destination? Any way of implementing startActivityForResult()?

If not, what would be my best bet? I've been considering running a service in the background that keeps tabs on the location and ending Google Navigation and returning to my app when the GPS registers that it's near the destination (because I know the latitude/longitude).

Thanks folks

mattbasta
  • 13,492
  • 9
  • 47
  • 68
  • Can you give more details on how you build location string? I tried lat+long and long+lat and navigation won't recognize it. – katit May 26 '11 at 18:56
  • @katit: It was undocumented at the time, don't know about now. This has some info: http://stackoverflow.com/questions/2662531/launching-google-maps-directions-via-an-intent-on-android, but my best advice is to try `lat,lon` where `lat` and `lon` are your coordinates. – mattbasta May 27 '11 at 21:36

1 Answers1

5

I wanted to post how I managed to get this to work. I'm not using activity callbacks, but I am starting a service with a LocationManager hanging out in it. When the user gets close to the destination coordinates, I just terminate Google Navigation and start my activity back up.

mattbasta
  • 13,492
  • 9
  • 47
  • 68