I am trying to send data from Android app to server .... but on click to save button causes android.os.NetworkOnMainThreadException and app stops.
Please can anyone help?
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://farahkhan.byethost15.com/try.php");
try {
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
       nameValuePairs.add(new BasicNameValuePair("username", "01"));
       nameValuePairs.add(new BasicNameValuePair("email", signupemailString));
       httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
       httpclient.execute(httppost);
       signupemail.setText(""); //reset the message text field
        Toast.makeText(getBaseContext(),"Sent",Toast.LENGTH_SHORT).show();
} catch (ClientProtocolException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
 
     
     
     
    