Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Open Google Navigation application from Intent

I am developing navigation base application. In these application, I have to open Map application to draw path between source & destination latitude/address with Traffic Enable.

I already create functionality to open Google map through Intent and draw the path between two points.

Is it possible that, to add Traffic Layer at time of passing Intent? Or Which parameter I need to add?

Thanks in advance.

like image 768
Dhruv Avatar asked Sep 29 '22 00:09

Dhruv


1 Answers

You can do this way:

I have considered my start location as current location.

Your destination location will be dynamic, as provided below:

double destinationLatitude = 22.3000;
double destinationLongitude = 73.2003;

 String url = "http://maps.google.com/maps?f=d&daddr="+ destinationLatitude+","+destinationLongitude+"&dirflg=d&layer=t";
 Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); 
 intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
 startActivity(intent);  

Done

like image 126
Hiren Patel Avatar answered Oct 04 '22 04:10

Hiren Patel