来自Android的对PHP文件的HTTP请求

This is simple I am sure but I am missing something. I want to use android to run a distant PHP file - that writes to a text file. I want to do this as part of learning about making requests over networks using android. I don't want any text back from the PHP file, and I don't want it to take any data. I only want it to run.

I am using this in my android mainActivity file

        try {
        String url = "http://cinderellagasman.com/ANDROID/connect.php";
        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(new HttpGet(url));

        } catch (IOException e) {
        //do something here

        }

but it immediately crashes. I only get this; "PropertyFetcher: AdbCommandRejectedException getting properties for device emulator-5554: device offline" in my ADB logs.

The emulator appears to be working OK. I have enabled Internet permission in the manifest file. The PHP I am wanting to run is

`$file = "data.txt";
 $handle = fopen($file, "a");
 $now = date('l jS \of F Y h:i:s A');
 fwrite($handle, $now."
");
 echo "hello";`

Suggestions welcome, am at basic level here and usually find answers without asking..

enter code hereProcess: com.example.douglas.connect_php, PID: 2879
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.douglas.connect_php/com.example.douglas.connect_php.MainActivity}: android.os.NetworkOnMainThreadException