Unable to open the stream coming from google map api in android? -


when using below url drawing route on map on android:

stringbuilder urlstring = new stringbuilder();       urlstring.append("http://maps.google.com/maps?f=d&hl=en");      urlstring.append("&saddr=");      urlstring.append(src);      urlstring.append("&daddr=");//      urlstring.append(dest);      urlstring.append("&ie=utf8&0&om=0&output=kml"); 

its throwing exception when urlconnection.getinputstream called.

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

new code:

document doc=null;          try         {               string url = geturl(p, q);             documentbuilderfactory dbfadd = documentbuilderfactory.newinstance();             documentbuilder dbadd = dbfadd.newdocumentbuilder();             doc = dbadd.parse(url.tostring()); 

iirc android's xml document parser cannot handle inputstream blocks. better use version of parse() download you, i.e. :

documentbuilderfactory dbf = documentbuilderfactory.newinstance(); documentbuilder db = dbf.newdocumentbuilder(); doc = db.parse(urlstring.tostring()); 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -