android - Can't fetch response from google finance using mobile data -
i want converted rate https://www.google.com/finance/converter?a=1&from=usd&to=bdt, works if device connected wifi. if call api using mobile data portion of response. there limit on mobile data response? or it's happening other reasons?
regards.
private class getconvertcurrency extends asynctask<string, void, string> { @override protected void onpreexecute() { super.onpreexecute(); } @override protected string doinbackground(string... strings) { httphandler sh = new httphandler(); string data=null; httpurlconnection urlconnection1st = null; httpurlconnection urlconnection2nd = null; httputil.disableconnectionreuseifnecessary(); string responsestr; stringbuffer buffer = new stringbuffer(); try { url=strings[0]; url urltorequest = new url(url); log.e("url",urltorequest.tostring()); httpurlconnection urlconnection = (httpurlconnection) urltorequest.openconnection(); try { bufferedreader bufferedreader = new bufferedreader( new inputstreamreader( urlconnection.getinputstream())); system.out.println("urlconnection.getresponsecode() = " + urlconnection.getresponsecode()); stringbuilder stringbuilder = new stringbuilder(); string line; while ((line = bufferedreader.readline()) != null) { stringbuilder.append(line).append("\n"); } bufferedreader.close(); return stringbuilder.tostring().trim(); } { urlconnection.disconnect(); } } catch(throwable t) { t.printstacktrace(); } return data; } @override protected void onpostexecute(string s) { stringbuffer buffer = new stringbuffer(); string data = null; if(s!=null){ document doc = null; doc = jsoup.parse(s); string title = doc.title(); buffer.append("title: " + title + "rn"); elements topiclist = doc.select("span.bld"); buffer.append("topic listrn"); (element topic : topiclist) { data = topic.text(); } } country_conversion_rate.put(countrydata.getprefix().trim(),s); if(data!=null)updateview(data); else updateviewwhenconversionratenull(); } }
Comments
Post a Comment