Java 如何获得横向和长Km值之和?

Java 如何获得横向和长Km值之和?,java,android,Java,Android,我使用了Stackoverflow: 距离计算器法 private String getDistanceOnRoad(double latitude, double longitude, double prelatitute, double prelongitude) { String result_in_kms = ""; String url = "http://maps.google.com/maps/api/directions/xml?origin="

我使用了Stackoverflow:

距离计算器法

private String getDistanceOnRoad(double latitude, double longitude,
        double prelatitute, double prelongitude) {
    String result_in_kms = "";
    String url = "http://maps.google.com/maps/api/directions/xml?origin="
            + latitude + "," + longitude + "&destination=" + prelatitute
            + "," + prelongitude + "&sensor=false&units=metric";
    String tag[] = { "text" };
    HttpResponse response = null;
    try {
        HttpClient httpClient = new DefaultHttpClient();
        HttpContext localContext = new BasicHttpContext();
        HttpPost httpPost = new HttpPost(url);
        response = httpClient.execute(httpPost, localContext);
        InputStream is = response.getEntity().getContent();
        DocumentBuilder builder = DocumentBuilderFactory.newInstance()
                .newDocumentBuilder();
        Document doc = builder.parse(is);
        if (doc != null) {
            NodeList nl;
            ArrayList args = new ArrayList();
            for (String s : tag) {
                nl = doc.getElementsByTagName(s);
                if (nl.getLength() > 0) {
                    Node node = nl.item(nl.getLength() - 1);
                    args.add(node.getTextContent());
                } else {
                    args.add(" - ");
                }
            }
            result_in_kms = String.format("%s", args.get(0));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result_in_kms;
}

但不知道如何使用double获得所有距离的总和,此方法返回字符串值,而我无法计算或求和字符串km值。

地图有预定义的方法来计算两个位置之间的距离(以米为单位)

firstLocation.distanceTo(currentLocation)

Double.parsedouble 12.88999;?不需要添加值吗?无法使用Double.parseDoubleresult_以_kms为单位获取总和;为什么?这有什么难办的?你犯了什么错误数字格式例外:谢谢你,我会试试的。。但有没有可能用上面的方法得到距离之和?我真的不知道,先生。