android - HttpGet试图运行php脚本

I'm trying to run a php script from my web server But for some reason the request keeps failing and going to the catch. Not sure what else I need to add to simply send a request to the server

public class MainActivity extends Activity {

    public void phpRequest()
    {
         HttpClient client = new DefaultHttpClient();
         final String url = "http://192.168.1.103/lock.php";

         try
         {
             client.execute(new HttpGet(url));
         }
         catch(Exception e)
         {
            Toast.makeText(getApplicationContext(), "Something went wrong", Toast.LENGTH_LONG).show(); 
         }


    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn_lock = (Button)findViewById(R.id.lock);
        Button btn_sleep = (Button)findViewById(R.id.sleep);
        Button btn_shutdown = (Button)findViewById(R.id.shutdown);

        btn_lock.setOnClickListener(new OnClickListener()
        {


            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                //Toast.makeText(getApplicationContext(), "Test", Toast.LENGTH_LONG).show();

                phpRequest();
            }

        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

I have already added INTERNET permission to my AndroidManifest.xml

The problem most likely is that you are calling the phpRequest method from the OnClickListener which runs on the UI thread. So you could simply start a new thread in the OnClickListener and start it like this:

new Thread() {
    public void run(){
        phpRequest();
    }
}.start();