在我的应用程序中,我使用以下代码打开Google地图。在特定设备上获取ActivityNotFoundException以打开Google地图
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);
而且它一直在许多设备上正常工作。但是今天我看到了ACRA的粉碎报告。
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)
设备是运行OS2.2.2的Vortex。例外清楚地告诉我,我需要在清单中声明“com.google.android.maps.MapsActivity”。问题是,我没有这样做,但它适用于很多设备,所以结果并不一致:为什么我在该设备上出现异常,并且没有获得其他许多设备?
请不要说“您需要将其添加到清单。”在这种情况下,请告诉我为什么一些(不是全部)设备毫无例外地工作。
在此先感谢。
您的map_url字符串无意中解决了我一直试图获取内置地图应用程序以开始作为意向时处理请求的持续问题。 “geo:0,0?q =”是关键,谢谢!像Abhinav说的 – samosaris