title: Android: Android App is not responding, close it?
body: <p>I have an application which sends data to a server and sometimes the following message appears: Android app is not responding , Close it? ( i don't know if is the same in English)</p>
  
  <p>It's difficult to see the log because it happens in one of 20 devices approximately when they are all working, and I can't see the log at that moment.
  I think the problem can be with the Asynctask function that sends data to the server.</p>
  
  <p>Here is the function:</p>
  
  <pre><code>class UpdateCandidatos extends AsyncTask&lt;String, String, String&gt; {
  
  protected String doInBackground(String... args) {
  
      List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
      params.add(new BasicNameValuePair("id", Nombres.getPID()));
      params.add(new BasicNameValuePair("test", nombre));
      params.add(new BasicNameValuePair("pregunta", npregunta));
      params.add(new BasicNameValuePair("bateria", levelstring));
      params.add(new BasicNameValuePair("correctas", correctasString));
      params.add(new BasicNameValuePair("errores", fallosString));
  
      JSONObject json = jsonParser.makeHttpRequest(url_update,
              "POST", params);
  
      try {
          int success = json.getInt(TAG_SUCCESS);
  
          if (success == 1) {
  
          } else {
  
          }
      } catch (JSONException e) {
          e.printStackTrace();
      }
      return null;
  }
  }
  </code></pre>
  
  <p>When it is called the asynctask function:</p>
  
  <pre><code>bNext.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
      count++;
      if (radBotA.isChecked()) {
          Respuestas[posicion] = "A";
      }
      else if (radBotB.isChecked()) {
          Respuestas[posicion] = "B";
      }
      else if (radBotC.isChecked()) {
          Respuestas[posicion] = "C";
      }
      else if (radBotD.isChecked()) {
          Respuestas[posicion] = "D";
      }
      else {
          Respuestas[posicion] = "";
      }
      if (Titulacion.IsReachable1(getApplicationContext())) {
          Correccion();
          new UpdateCandidatos().execute();
      }
  }
  });
  </code></pre>
  
  <p>The message appears after there is some time that even you click on any button the app continues blocked. Is there anything wrong on my asynctask function? How Could I solve this problem?</p>
  
  <p>Edit: Correccion() is comparing 2 arrays.</p>
  
  <pre><code>public void Correccion(){
                  correctas = 0;
                  fallos = 0;
                  sinresponder  = 0;
          for(int posicion=0;posicion&lt;=nPreguntas-1;posicion++){
  if(Respuestas[posicion].equals(RespuestasC[posicion])){
  
      correctas++;
  }
  else if(Respuestas[posicion].equals("")){
      sinresponder++;
  }
  else{
      fallos++;
  }
          }
          correccion++;
          correctasString = String.valueOf(correctas);
          fallosString = String.valueOf(fallos);
              }
  </code></pre>
  
  <p>isReachable() is used in order to know if the device can reach the Server.</p>
  
  <pre><code>public static boolean IsReachable1(Context context) {
          final ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
          final NetworkInfo netInfo = connMgr.getActiveNetworkInfo();
          boolean isReachable = false;
  
          if (netInfo != null &amp;&amp; netInfo.isConnected()) {
              try {
                  URL url = new URL("http://10.0.0.15/");
                  HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
                 urlc.setConnectTimeout(1 * 200);
                  urlc.connect();
                  isReachable = (urlc.getResponseCode() == 200);
              } catch (IOException e) {
  
                  Log.e("TAG", e.getMessage());
              }
          }
  
          return isReachable;
      }
  </code></pre>