Reputation: 1279
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.
Upvotes: 0
Views: 844
Reputation: 1038
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.
Upvotes: 0
Reputation: 3339
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);
Upvotes: 1