Tomcat
Tomcat

Reputation: 1415

Getting ActivityNotFoundException on specific device to open Google Maps

In my app I open Google Maps with following code.

String map_url = "geo:0,0?q=";
map_url += String.valueOf((double)latitude / 1E6) + ",";
map_url += String.valueOf((double)longitude / 1E6);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
intent.setData(Uri.parse(map_url));
startActivity(intent);

And it has been working fine with many devices. But today I saw ACRA's crush report.

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.apps.maps/com.google.android.maps.MapsActivity}; have you declared this activity in your AndroidManifest.xml?
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
    at android.app.Activity.startActivityForResult(Activity.java:2817)
    at android.app.Activity.startActivity(Activity.java:2923)

The device is Vortex running OS2.2.2. Exception clearly tells me I need to declare "com.google.android.maps.MapsActivity" in manifest. The question is, I did not do this but it works for many devices, so result is not consistent: Why I get exception on that device and I did not get for many other devices?

Please not saying "You need to add that to manifest." In that case, please tell me why some (not all) devices work without exception.

Thanks in advance.

Upvotes: 2

Views: 2730

Answers (1)

Abhinav
Abhinav

Reputation: 39952

com.google.android.maps is a different application/package so declaring it in your AndroidManifest won't give you what you want. I believe the Android installation does not have the Maps application installed and hence can not receive the fired Intent.

Upvotes: 3

Related Questions