Używam trasy mapy google do mojej własnej aplikacji na Androida. 2 dni temu działało dobrze, ale po tym, gdy aplikacja uruchamia swoje dawanie mi błędów za pomocą logcat. Czy jakiekolwiek ciało może mi podać przyczynę i rozwiązanie tego problemu.Błąd odniesienia niezerokowanego obiektu
org.xml.sax.SAXParseException: unterminated entity ref (position:ENTITY_REF &@1:799 in [email protected])
private String[] getDirectionData(String sourceLat, String sourceLong, String destinationLat, String destinationLong) {
String urlString = "http://maps.google.com/maps?f=d&hl=en&" +"saddr="+sourceLat+","+sourceLong+"&daddr="+destinationLat+","+destinationLong + "&ie=UTF8&0&om=0&output=kml";
Log.d("URL", urlString);
Document doc = null;
HttpURLConnection urlConnection = null;
URL url = null;
String pathConent = "";
try {
url = new URL(urlString.toString());
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.connect();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(urlConnection.getInputStream());
} catch (Exception e) {
Log.w("Error in google map",e);
}
NodeList nl = doc.getElementsByTagName("LineString");
for (int s = 0; s < nl.getLength(); s++) {
Node rootNode = nl.item(s);
NodeList configItems = rootNode.getChildNodes();
for (int x = 0; x < configItems.getLength(); x++) {
Node lineStringNode = configItems.item(x);
NodeList path = lineStringNode.getChildNodes();
pathConent = path.item(0).getNodeValue();
}
}
String[] tempContent = pathConent.split(" ");
return tempContent;
}
dodać niektóre kodu i adresu obrazu na pytanie – hasanghaforian
oh, znalazł doskonałą odpowiedź na tym forum [link do pasującej odpowiedzi] [1] [1]: http://stackoverflow.com/questions/11745314/why-retrieving-google-directions -nie-Android-używa-kml-dane-nie-działa-anymo – 2red13