Ejemplo n.º 1
0
  private void executeHttpPostAsync(Activity activity, String UrlService) {
    if (isInternetAllowed(activity)) {
      try {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(UrlService);
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        setResponseBody(httpclient.execute(httppost, responseHandler));

        activity.runOnUiThread(returnRes);
      } catch (HttpResponseException hre) {
        ListenerExecuteHttpPostAsync.onErrorHttpPostAsyncListener(
            activity.getString(R.string.errorConectandoServer));
      } catch (Exception e) {
        ListenerExecuteHttpPostAsync.onErrorHttpPostAsyncListener(
            activity.getString(R.string.errorConectando));
      }
    } else {
      ListenerExecuteHttpPostAsync.onErrorHttpPostAsyncListener(
          activity.getString(R.string.conexionNoPosible));
    }
  }
Ejemplo n.º 2
0
 public void run() {
   m_ProgressDialog.dismiss();
   ListenerExecuteHttpPostAsync.onExecuteHttpPostAsyncListener(getResponseBody());
 }