Reputation: 199
I am trying to link an address in a list view item which will allow the location of a tourist attraction to appear on google maps. I am experiencing an error when I do this and the app crashes. In the log, the following error appears:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=google.streetview:cbll=46.414382,10.013988 pkg=com.google.android.apps.maps }
I am using the code which is on the Google developers website but it doesn't seem to work. The code is below:
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
mContext.startActivity(mapIntent);
I have added the mContext
as this previously had an error before.
Can anyone please help?
Upvotes: 2
Views: 2515
Reputation: 10126
This happens when Google Maps app is not installed on the device/emulator. You need to install google maps or some other map application.
Try
Uri gmmIntentUri = Uri.parse("http://maps.google.com/maps?daddr=37.7749,-122.4194");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
//mapIntent.setPackage("com.google.android.apps.maps");
mContext.startActivity(mapIntent);
Upvotes: 2
Reputation: 283
try this :
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?daddr="+dlat+","+dlng));
startActivity(intent);
Upvotes: 1