0

With the help of following code i am trying to open Google map application but its getting crash after 2 min of loading.

Code snippet :

String url = "http://maps.google.com/maps?saddr="
                    + GPS_Data.getLatitude() + "," + GPS_Data.getLongitude()
                    + "&daddr=" + mCompanyDetail.getLatitude() + ","
                    + mCompanyDetail.getLongitude() + "&mode=driving";
            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);

Note : input from my side is fine and i am not getting any logs regarding this.

Manish
  • 1,259
  • 3
  • 11
  • 20

2 Answers2

1

try using this way also added permission

double latitude = 40.714728;
double longitude = -73.998672;
String label = "ABC Label";
String uriBegin = "geo:" + latitude + "," + longitude;
String query = latitude + "," + longitude + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery + "&z=16";
Uri uri = Uri.parse(uriString);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);

Reference

Community
  • 1
  • 1
Naveen Tamrakar
  • 3,349
  • 1
  • 19
  • 28
  • @Naveen-Although it dosen't give me the driving path but i can live with that..thanks man!! – Manish Jan 16 '15 at 06:51
0

The first diagnostic is to wrap your code inside a try{}catch{} block

try {
     ...
} catch (Exception e) {
     // This will catch any exception, because they are all descended from Exception
}

And then write the exception into a log file or any any other way. This will allow to be sure that the issue is caused by any thrown error in the code or else it could also be a problem with the resources on the device. If you're testing on an emulator, then try to increase the resources on the device. Also try to fetch the debugger response through ADB.

Anurag
  • 1,018
  • 1
  • 14
  • 36