-3

I have this code's string:

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&saddr=37.4,-121.9&daddr=Bellevue WA&hl=en"));

Using this code, Google maps creates the path from coordinates "37.04,-121.9" to "Bellevue". Now I wouldn't to add in the path the static coordinates (37.04;-121.9) but 2 variables called "long" and "lat". How I can do? like this:

   Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&saddr=long,lat&daddr=Bellevue WA&hl=en"));

but in this way, it doesn't work. Anyone can help me? Thanks

Parker
  • 8,273
  • 10
  • 67
  • 95

1 Answers1

2

You have to construct the URI String first.

You can use:

String uri = String.format("http://maps.google.com/maps?f=d&saddr=%1$s,%2$s&daddr=Bellevue WA&hl=en", long, lat);
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
Raymond Lukanta
  • 520
  • 3
  • 14