Peticiones http android problema
Tengo esta clase en android que la he implementado utilizando las librerías de java y apache para realizar peticiones http:
public void executeHttpPostSync(){
if(isInternetAllowed(context))
{
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(UrlService);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String respuesta = httpclient.execute(httppost, responseHandler);
setResponseBody(respuesta);
}
catch(HttpResponseException hre)
{
ListenerExecuteHttpPostAsync.onErrorHttpPostAsyncListener("Se ha producido un error al conectar con el servidor");
}
catch(Exception e)
{
ListenerExecuteHttpPostAsync.onErrorHttpPostAsyncListener("Se ha producido un error");
}
}
else
{
ListenerExecuteHttpPostAsync.onErrorHttpPostAsyncListener("No es posible realizar la conexión. Comprueba tu conexión de datos.");
}
}Me está lanzando la excepcion por el catch (Exception e). He testeado el service en local con la herraienta poster y funciona bien. Alguien sabe por qué? Este código lo he utilizado ya en varias apps y nunca me ha dado errores