Android从变量启动Google地图路线

时间:2013-10-10 07:09:48

标签: android google-maps

我想从Variable edittext或textview中发布Google Maps Directions任何人都可以帮助我吗? 这是我的java代码:

    StringBuilder stringbuilder = new StringBuilder("http://maps.google.com/maps?daddr=");
    double d = -6.559759;
    StringBuilder stringbuilder1 = stringbuilder.append(d).append(",");
    double d1 = 106.785973;
    Uri uri = Uri.parse(stringbuilder1.append(d1).toString());
    Intent intent = new Intent("android.intent.action.VIEW", uri);
    startActivity(intent);

1 个答案:

答案 0 :(得分:0)

试试这个 -

   final Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://maps.google.com/maps?f=d&saddr="+currentLatitude+","+currentLongitude+"&daddr="+dest_Latitude+","+dest_Longitude));
            intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
            context.startActivity(intent);