Android Application While Loop Error -


i've text file in partners computer hosted on server. i'm attempting retrieve string values in text file in android application. however, application doesn't enter while loop method read text file. there way solve it? computer connected partners server.

code method.

connect.setonclicklistener(new view.onclicklistener(){      public void onclick(view v){          thread trd = new thread(new runnable(){              @override              public void run(){                  //code http request                  try {                      url url = new url("insert url");//your website link                      httpurlconnection con = (httpurlconnection)url.openconnection();                      bufferedreader br = new bufferedreader(new inputstreamreader(con.getinputstream()));                      string line;                      while((line = br.readline()) != null){                          result.settext(line);                      }                      con.disconnect();                  } catch(ioexception e) {                      system.out.println("error");                  }              }         });         trd.start();     } }); } 

while((line = br.readline()) != null)  {     result.settext(line);  } 

result can not run in thread different ui thread. use

while((line = br.readline()) != null)  { final string finalline = line;  runonuithread(new runnable() {  @override  public void run() {        result.settext(finalline);   } }); } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -