【问题标题】:Google Map app getting crash while opening from my app从我的应用程序打开时谷歌地图应用程序崩溃
【发布时间】:2015-01-16 06:22:49
【问题描述】:

在以下代码的帮助下,我试图打开 Google 地图应用程序,但在加载 2 分钟后它就崩溃了。

代码 sn-p:

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);

注意:我这边的输入很好,我没有收到任何关于此的日志。

【问题讨论】:

  • 请先检查您的位置。!!

标签: android google-maps android-intent


【解决方案1】:

尝试使用这种方式也添加了权限

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

【讨论】:

  • @Naveen-虽然它没有给我驾驶路径,但我可以忍受......谢谢男人!
【解决方案2】:

第一个诊断是将代码包装在 try{}catch{} 块中

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

然后将异常写入日志文件或任何其他方式。这将确保问题是由代码中的任何抛出错误引起的,否则它也可能是设备上的资源问题。如果您在模拟器上进行测试,请尝试增加设备上的资源。也尝试通过 ADB 获取调试器响应。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-15
    • 1970-01-01
    • 1970-01-01
    • 2012-11-27
    相关资源
    最近更新 更多