Ejemplo n.º 1
0
    protected String doInBackground(String... params) {
      Log.i(TAG, "doInBackground");
      String respuesta = null;

      try {
        TelephonyManager telephonyManager =
            (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String IMEI = telephonyManager.getDeviceId();
        String IMSI = telephonyManager.getSimSerialNumber();
        String consulta;
        if (phone.getText().toString().equals("2")) {
          consulta = URLs.RESOURCE;
        } else consulta = SoapRequestMovistar.getResource(IMEI, IMSI, phone.getText().toString());

        ArrayList<String> retorno = XMLParser.getReturnCode(consulta);

        code = Integer.valueOf(retorno.get(0));

        if (code == 0) {
          respuesta = consulta;
          Log.i(TAG, retorno.get(1));
        } else respuesta = retorno.get(1);
        return respuesta;

      } catch (HttpHostConnectException e2) {
        errorMessage = "Se agotó el tiempo de espera. Por favor reintente";
        return null;
      } catch (HttpResponseException e3) {
        e3.printStackTrace();
        errorMessage = "Se agotó el tiempo de espera. Por favor reintente";
        return null;
      } catch (ParseException p) {
        p.printStackTrace();
        errorMessage = "Error en la recepción de los datos. Por favor reintente";
        return null;
      } catch (SocketTimeoutException s1) {
        s1.printStackTrace();
        errorMessage = "Se agotó el tiempo de espera. Por favor reintente";
        return null;
      } catch (ConnectTimeoutException et) {
        et.printStackTrace();
        errorMessage = "Se agotó el tiempo de espera. Por favor reintente";
        return null;
      } catch (Exception e1) {
        e1.printStackTrace();
        errorMessage = "Ha ocurrido un error con la respuesta del servidor.";
        return null;
      }
    }
    @Override
    protected ArrayList<MapMarker> doInBackground(String... params) {
      ArrayList<MapMarker> respuesta;

      try {
        TelephonyManager telephonyManager =
            (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String IMEI = telephonyManager.getDeviceId();
        String IMSI = telephonyManager.getSimSerialNumber();

        String output = SoapRequestMovistar.getMapMarkers(IMEI, IMSI, comuna, region);
        // String output = dummy();
        if (output != null) respuesta = XMLParser.getMapMarkers(output);
        else respuesta = null;

      } catch (Exception e) {
        e.printStackTrace();
        respuesta = null;
      }
      return respuesta;
    }
Ejemplo n.º 3
0
    @Override
    protected String doInBackground(String... params) {
      TelephonyManager telephonyManager =
          (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
      String IMEI = telephonyManager.getDeviceId();
      String IMSI = telephonyManager.getSimSerialNumber();
      try {
        String query = SoapRequestMovistar.getButtonBlock(IMEI, IMSI);
        // String query = URLs.BLOQUEO;
        ArrayList<Boton> response = XMLParser.getButtons(query);

        for (Boton b : response) {
          if (b.isActualizacion()) actualizar = b;
          else {
            bloqueo.setBloqueo(b.getId(), b.isEnabled(), b.getName());
          }
          ok = true;
        }
        return "BLOQUEO OK";
      } catch (SAXException e) {
        e.printStackTrace();
        return "Error al leer el xml";
      } catch (ParserConfigurationException e) {
        e.printStackTrace();
        return "Error al leer el xml";
      } catch (XPathExpressionException e) {
        e.printStackTrace();
        return "Error al leer el xml";
      } catch (IOException e) {
        e.printStackTrace();
        return "Se agotó el tiempo de espera con el servidor. Compruebe su conexión a internet y reinicie la aplicación";
      } catch (Exception e) {
        e.printStackTrace();
        return "Error no controlado:\n" + e.getMessage();
      }
    }