These codes are executed after a button is pressed. I'm trying to send the strings data to the php file in my server. But the application has stopped after i pressed the button. Can i know whats the problem here? Any helps are really appreciated :D
HttpClient client = new DefaultHttpClient();
HttpPost hpost = new HttpPost("http://myservername.com/postTest.php");
status = mStatus.getText().toString();
event = mEvent.getText().toString();
time = mTime.getText().toString();
try{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("status", status));
nameValuePairs.add(new BasicNameValuePair("event", event));
nameValuePairs.add(new BasicNameValuePair("time", time));
hpost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
client.execute(hpost);
mStatus.setText("");
mEvent.setText("");
mTime.setText("");
}catch (UnsupportedEncodingException e){
Toast.makeText(this, "Unsupported Encoding Exception " + e.getMessage(), Toast.LENGTH_LONG).show();
}catch (ClientProtocolException e){
Toast.makeText(this, "Client Protocol Exception " + e.getMessage(), Toast.LENGTH_LONG).show();
}catch (IOException e){
Toast.makeText(this, "IO Exception "+e.getMessage(), Toast.LENGTH_LONG).show();
}