Search code examples
androidandroid-layoutandroid-mapviewandroid-mapsandroid-maps-v2

How to open navigation instead of mapview in android?


I have plotted location and if it has been clicked, it goes to maps and from maps, if it has been clicked direction, it opens google navigation.Is it possible to directly link with navigation?

I have defined the code like this.

GeoPoint pt = item.getPoint();

String lat = Double.toString(pt.getLatitudeE6() / 1e6);

String lng = Double.toString(pt.getLongitudeE6() / 1e6);

intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=" + lat + "," + lng));

In uri, what should be given to open navigation? I want to skip 2nd screenshot and directly

open navigation. how to do this?

My Screenshot are as follows:

1st screenshot

2nd screenshot here

3rd screenshot


Solution

  • However I found a solution

    Intent intent;
    GeoPoint pt = item.getPoint();
    String lat = Double.toString(pt.getLatitudeE6() / 1e6);
    String lng = Double.toString(pt.getLongitudeE6() / 1e6);               
    intent = new Intent(android.content.Intent.ACTION_VIEW,
    Uri.parse("google.navigation:q=" + lat + "," + lng));