I want to post my data to the php server. But it doesn't work when I click the button. I`ve added Internet permission in Manifest.xml.
What is problem in my code ?
public class MainActivity extends Activity {
Button sendButton;
EditText msgTextField, msgTextField2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
msgTextField = (EditText) findViewById(R.id.msgTextField);
msgTextField2 = (EditText) findViewById(R.id.msgTextField2);
sendButton = (Button) findViewById(R.id.send);}
public void send(View v) { //View v ?
String msg = msgTextField.getText().toString();
String msg2 = msgTextField2.getText().toString();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(
"http://blahblah.com/myphppage");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("frm_ad", msg));
nameValuePairs.add(new BasicNameValuePair("frm_nomre", msg2));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
HttpResponse response = httpclient.execute(httppost);
msgTextField.setText("");
msgTextField2.setText("");
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
}
}