Posting to a URL with Android?
<p>OK, been stuck on this one for quite a while now. Not an expert with Java but been trying to create an app to simply post information to a URL. Don't know where my code is going wrong? Please can you have a look and advise? Sorry to upload loads of code don't really know how to explain it as I don't know where I am going wrong. No errors in the console, emulator just fails to load app fully?</p>

<pre><code>import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;


public class test {


public void postData() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");

    try {
        // Add your data
        List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
        nameValuePairs.add(new BasicNameValuePair("id", "name"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        httpclient.execute(httppost);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block
    }
}

  }

   &lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;

    &lt;EditText
    android:id="@+id/name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="72dp"
    android:layout_marginTop="36dp"
    android:ems="10"
    android:inputType="text"
    android:text="@string/Enter_name" &gt;


       &lt;Button
    android:id="@+id/Submit_Transaction"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="40dp"
    android:layout_toRightOf="@+id/textView1"
    android:onClick="postData()"
    android:text="@string/Submit_Tran_Button" /&gt;

    &lt;activity
        android:name="com.testing.myappname.PostData"
        android:label="@string/app_name" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
</code></pre>

<p>LogCat starts with FATAL EXCEPTION MAIN error then...</p>

<p>01-21 21:52:44.459: E/AndroidRuntime(1155): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.test.testing/com.testing.testing.PostData}: java.lang.ClassNotFoundException: Didn't find class "com.testing.testingvt.PostData" on path: /data/app/com.testing.testingvt-1.apk</p>
