Androidアプリからサーバーにデータを送信しようとしています....しかし、クリックして保存ボタンをクリックするandroid.os.NetworkOnMainThreadException
と、アプリが停止します。誰でも助けてください。
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();
}