java - Why do i get a 'Cannot resolve symbol 'execute''? -


i imported httpclient packages , wanted use .addheader , .execute, error 'cannot resolve symbol 'execute'' , 'cannot resolve symbol 'addheader'' though imported necessary packages.

public class myactivity extends activity { public textview quellcode; public textview geschichte; private string string1 = "gahwareawbad password gagaw";   @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);     quellcode = (textview) findviewbyid(com.example.mainactivity.r.id.textview01);     geschichte = (textview) findviewbyid(com.example.mainactivity.r.id.geschichte);     readwebpage(quellcode);     }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     //getmenuinflater().inflate(r.menu.main, menu);     return true; } private class downloadwebpagetask extends asynctask<string, void, string> {      //automatic login       //end of login      //read webpage     @override     protected string doinbackground(string... urls) {         string response = "";         downloadpage("http://www.besselgymnasium.de/fileadmin/vertretung/vertretungsplan_schueler/subst_001.htm");         (string url : urls) {             defaulthttpclient client = new defaulthttpclient();             httpget httpget = new httpget(url);             try {                 httpresponse execute = client.execute(httpget);                 inputstream content = execute.getentity().getcontent();                  bufferedreader buffer = new bufferedreader(new inputstreamreader(content));                 string s = "";                 while ((s = buffer.readline()) != null) {                     response += s;                 }              } catch (exception e) {                 e.printstacktrace();             }         }         return response;      }     //end of reading     private void downloadpage (string url){         try{             url obj = new url(url);             // send post request             httpurlconnection con = (httpurlconnection) obj.openconnection();             con.setdooutput(true);             dataoutputstream wr = new dataoutputstream(con.getoutputstream());             wr.writebytes("username"+"password");             wr.flush();             wr.close();             inputstream = con.getinputstream();             inputstreamreader isr = new inputstreamreader(is,"iso-8859-1");             bufferedreader br = new bufferedreader(isr);             (string line = br.readline(); line != null ; line = br.readline()) {                 // variable line contains line of text. can insert in database of file             }             con.disconnect();         } catch (exception e){             // todo error handling         }     }     @override     protected void onpostexecute(string result) {         quellcode.settext(result);          //check if class canceled         if(quellcode.gettext().tostring().contains("eigenverant. arb.") && quellcode.gettext().tostring().contains("pön")){             geschichte.settext("output: success!");         }else{             geschichte.settext("output: fail!");         }          //end of check       } }   public void readwebpage(view view) {     downloadwebpagetask task = new downloadwebpagetask();     task.execute(new string[]{"http://www.besselgymnasium.de/fileadmin/vertretung/vertretungsplan_schueler/subst_001.htm"});  } 

}

use doinbackground executing request in background thread as:

 protected string doinbackground(string... urls) {           // call httpclient.execute(request); here     httpurirequest request = new httpget("http://www.besselgymnasium.de/"+                  "fileadmin/vertretung/vertretungsplan_schueler/subst_001.htm");     string credentials = "username" + ":" + "password";   string base64encodedcredentials =                    base64.encodetostring(credentials.getbytes(), base64.no_wrap);    request.addheader("authorization", "basic " + base64encodedcredentials);    httpclient httpclient = new defaulthttpclient();   httpclient.execute(request);          return null;      } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -