localhost - how to print response in android app -


hi new android , trying post data localhost not getting response or error

public void postdata(string valueiwanttosend) { // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://10.0.2.2/text.php");  try { // add data list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("myhttpdata", valueiwanttosend)); httppost.setentity(new urlencodedformentity(namevaluepairs));  // execute http post request httpresponse response = httpclient.execute(httppost);  } catch (clientprotocolexception e) { // todo auto-generated catch block } catch (ioexception e) { // todo auto-generated catch block } 

please suggest me how can print response can come know issue

from response:

 stringbuilder builder = new stringbuilder();  int statuscode = response.getstatuscode();   if (statuscode == 200) {     httpentity entity = response.getentity();     inputstream content = entity.getcontent();     bufferedreader reader = new bufferedreader(new inputstreamreader(content));     string line;     while ((line = reader.readline()) != null) {       builder.append(line);     }   } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -