I have an android application running and I need to send a few URL races quickly and easily.
I use this code to execute this function, but it is already obsolete and sometimes it does not work as it should! Thanks in advance for your help.
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();
}
}
});
}