1
I have an android app running and need to send some parameters per URL quickly and easily to run.
I use this code to perform this function, but it is already obsolete and sometimes it does not work as it should! I appreciate the help of all.
public void sendRegisterTime(String id, String horaRegister, String image){
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(ipConnectionServer+dirInsertTimer);
try{
ArrayList<NameValuePair> valores = new ArrayList<NameValuePair>();
valores.add(new BasicNameValuePair("cod", id));
valores.add(new BasicNameValuePair("hora", horaRegister));
valores.add(new BasicNameValuePair("img", image));
httpPost.setEntity(new UrlEncodedFormEntity(valores));
final HttpResponse resposta = httpClient.execute(httpPost);
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
if(EntityUtils.toString(resposta.getEntity()).equals("success")){
successLayout();
}else{
failedLayout();
}
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
gives a look at this lib: https://github.com/hgoebl/DavidWebb
– itscorey
Related Error using apache Httpclient class
– ramaral