HTTP Responses - Android -


I am trying to post my application on my webserver (located at IP 10.0.2.2) and get feedback . I am using an HttpHelper object to perform all server-interaction methods. Currently, my feedback variable is not getting something back through debugging I know that loop:

  while ((Line = rd.readline ()) = null {{code>  

is never recorded, but

Thank you very much for your help!

The webpage code is just:

/ P>

  header ("HTTP / 1.1 200 OK");   

The Java code is:

  list & lt; NameValuePair & gt; Data = new arreelist & amp; Name; Valuepayer & gt; (); HttpHelper httpHelper = New HttpHelper ("http: //10.0.2.2/", data); Stringbinder feedback = httpHelper.postData ();   

...

  public class HttpHelper {Final HTT client client; Last HTTPS Post Post; Last list & lt; NameValuePair & gt; Information; Public HTTPHelper (String Address, List & Name; NameValuePair & gt; Data) {Client = New DefaultHttpClient (); Post = new HTTP post (address); This.data = data; } Private class GetResponseTask AsyncTask Extended & lt; Zero, zero, stringbuilder & gt; {Protected stringbilder Diazackground (zero ... request) {try {HTPRS response = Client. Execute (post); Return InputStreamToString (Response Geetitity (.) GetContent ()); } Hold (Client Protocol Exception E) {Log.e ("Debug", E.A.T.L.Klized Message ()); } Grip (IOE EXPRESS E) {Log.e ("debug", E.A.O.Oolociled Message ()); } Return tap; }} Public StringBuilder postData () {try {post.setEntity (new UrlEncodedFormEntity (data)); Return (execute new GetResponseTask (). ()). Get (); } Hold (unsupported encoding exception e) {Log.e ("debug", E..T.O.Localized Message ()); } Grip (Interrupted ejection) {Log.e ("debug", E..T.O.Localized Message ()); } Hold (Execution Exception E) {Log.e ("Debug", E.A.O.Oolociled Message ()); } Return tap; } Private stringbilder inputstream throwing (inputstream) throws IOException {string line = ""; StringBiller Total = New StringBuilder (); // InputStream BufferedReader rd = A BufferedReader Wrap (New InputStreamReader) around the new BufferedReader; // Read the response until the end ((line = rd.readline ()) = null) {Log.v ("debug", "readloop top"); Total.append (line); Logs. V ("debug-redline", line); } // return complete string return total; }}    

response unit, returned by getEntity (), is not included in it The response header, and it looks like you're interested. To obtain the status code, use it:

  response.getStatusLine (). GetStatusCode ()    

Edit: To emit contents from PHP, echo , print_r () , < Use code> Var_dump () , many other functions, and - most importantly - tag.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

c# - Confused over DLL entry points (entry point not found exception) -