android - Clarification needed regarding invoking a library -


please can me out usage of android libraries.

  1. i hit go button needs invoke library.
  2. library in turn launches login screen
  3. the login screen accepts user id,password hits url , gives response(success/failure)

the code http post(which needs used library) :

username = (edittext) findviewbyid(r.id.edittextusername); password = (edittext) findviewbyid(r.id.edittextpassword);

     submit = (button)findviewbyid(r.id.submit);        submit.setonclicklistener(new view.onclicklistener() {  @override public void onclick(view v) {      // todo auto-generated method stub     if(username.gettext().length()>0 && password.gettext().length()>0)     {         urlconnector ss = new urlconnector();         ss.execute("http//ipchicken.com");     } } 

});

}  private class urlconnector extends asynctask<string, void, string> {      @override     protected string doinbackground(string... urls) {         string response = "";         (string url : urls) {              defaulthttpclient httpclient = new defaulthttpclient();             httppost httppost = new httppost(url);             try {                    list<namevaluepair> postparameters = new arraylist<namevaluepair>();                    urlencodedformentity formentity = new urlencodedformentity(                         postparameters);                  httppost.setentity(formentity);                  httpresponse response1 = httpclient.execute(httppost);                  bufferedreader in = new bufferedreader(                         new inputstreamreader(response1.getentity()                                 .getcontent()));                 stringbuffer sb = new stringbuffer("");                  string line = "";                 string nl = system.getproperty("line.separator");                 while ((line = in.readline()) != null) {                     sb.append(line + nl);                 }                 in.close();                  string result = sb.tostring();                 response = result;                 system.err.println("my response :: " + result);              } catch (clientprotocolexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }         }         return response;      }      protected void onpostexecute(string result) {         if(result != null)         {         intent tokenintent = new intent(mcontext, tokenactivity.class);          bundle bundle = new bundle();          bundle.putstring("responsedata",result);          tokenintent.putextras(bundle);         startactivity(tokenintent);         } 


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -