Android Studio program seems to be getting stuck at HTTPResponse -


i'm working on app in android studio, i'm relatively new , i'm trying pull information website. i'm running problem. code seems sticking @ httpresponse request. i've stuck load of debug logs in , last 1 print "log.v("arg", "trying 2");". i've included applicable code below, can maybe point out i'm doing wrong? appreciated.

@override     protected string doinbackground(string... medurls) {         log.v("arg", "executed");         string medname = "medname";         (string medsearchurl : medurls) {             httpclient medclient = new defaulthttpclient();             log.v("arg", medsearchurl);             try {                 log.v("arg", "trying 1");                 httpget medget = new httpget(medsearchurl);                 log.v("arg", "trying 2");                 httpresponse medresponse = medclient.execute(medget);                 log.v("arg", "trying 3");                 statusline medsearchstatus = medresponse.getstatusline();                 log.v("arg", "before if");                 if (medsearchstatus.getstatuscode()==200) {                     httpentity medentity = medresponse.getentity();                      inputstream medcontent = medentity.getcontent();                     inputstreamreader medinput = new inputstreamreader(medcontent);                     bufferedreader medreader = new bufferedreader(medinput);                     log.v("arg", "in if statement");                     string linein;                     while ((linein=medreader.readline())!=null) {                         medname +=linein;                         log.v("arg", "in while loop");                     }                 }                 else{                     log.v("arg", "failed if statement");                 }             }             catch(exception e){                 e.printstacktrace();                 log.v("arg", "caught");             }             log.v("arg", "end of big loop");         }         log.v("arg", "about return");         return medname;     } 

i think should try httpurlconnection. can check 1 of tutorial..

http://www.tutorialspoint.com/android/android_network_connection.html http://www.vogella.com/tutorials/androidnetworking/article.html


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -