android:意图查看地图

时间:2014-01-04 02:30:15

标签: android android-intent map

我尝试通过手机缓存显示某些经度和纬度

myLocation = loc.getLastKnownLocation(LocationManager.GPS_PROVIDER);

但是,当我拨打viewmap(myLocation)时,它会崩溃......

 public void viewMap(Location loc){
    String uri = "geo:" + loc.getLatitude()+"," + loc.getLongitude() +
                 "?q=" + loc.getLatitude()+"," + loc.getLongitude() +
                 "(7 Dash)";

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    startActivity(intent);
}

1 个答案:

答案 0 :(得分:0)

试试这个

 public void viewMap(Location loc){
String uri = "geo:" + loc.getLatitude()+"," + loc.getLongitude() +
             "?q=" + loc.getLatitude()+"," + loc.getLongitude() +
             "(7 Dash)";

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
}