I had change from API23 to 22 because they said httpclient wasn't available.When I switched to API22 I had problem with HttpClient,HttpPost and NameValuePair.I found the solution to use HttpURLConnectionHandler.But I don't know how to use it for the following method.
public void send(View v)
{
HttpClient httpclient = new DefaultHttpClient();
// put the address to your server and receiver file here
HttpPost httppost = new HttpPost("http://yoursite/yourPHPScript.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
// we wont be receiving the parameter ID in your server, but it is here to show you how you can send more data
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
// message is the parameter we are receiving, it has the value of 1 which is the value that will be sent from your server to your Arduino board
nameValuePairs.add(new BasicNameValuePair("message", "1"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost); // send the parameter to the server
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
Someone kindly help me