Http requests for php pages from android
<p>I am trying to request for a php page from my android app. The response text is supposed to be in an EditText view. Well there is no response text. I dont know what am doin wrong but in a normal java class when i system.out.println the reponse, it actually shows. What is it with android?
Here is my code:</p>

<pre><code>package com.httprequests;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLConnection;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class httprequests extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
    Button btnRequest;
    EditText textRequest;
    TextView mytextView;
    BufferedReader buffereader;
    URLConnection conn;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        btnRequest=(Button)findViewById(R.id.btnRequest);
        textRequest=(EditText)findViewById(R.id.textRequest);
        mytextView=(TextView)findViewById(R.id.mytextView);

        btnRequest.setOnClickListener(this);
    }
    @Override
    public void onClick(View src) {
        if(src==btnRequest)
        {

            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httpost = new HttpPost("http://localhost/practice/index.php");
            HttpResponse response;
            try 
            {
                response = httpclient.execute(httpost);
                HttpEntity entity = response.getEntity();
                InputStream stream = entity.getContent();
                BufferedReader br=new BufferedReader(new InputStreamReader(stream));

                String str;
                while((str=br.readLine())!=null)
                {
                    mytextView.setText(str);
                }
            }
            catch(Exception e)
            {
                textRequest.setText(e.getMessage());
            }
            finally
            {
                try
                {
                    buffereader.close();
                }
                catch(Exception e)
                {
                    textRequest.setText(e.getMessage());
                }
            }
        }

    }
}   
</code></pre>
