title: screen freezes while running without debug
body: <p>In my Android app, we have a Autocomplete textview. We get the values to ve displayed to the autocomplete textview from Database (mysql accessed using Php scripts). The database returns around 45 values.
  In my android app I have a asynctask which reads the value and onPostexecute im binding the values to the autocomplete area textview. </p>
  
  <p>My Problem is when I debug and set breakpoints in my onPostExecute or somewhere the app works perfectly. When i run without debugging the screen freezes and does nothing. I don;t have a clue what's wrong here. Any anyone help!!</p>
  
  <p>My ASynctask: </p>
  
  <pre><code> public class AsyncGetCityList extends AsyncTask&lt;String, Void, String&gt; 
    {
      String orderdetailsurl = "URL for my DB";
  
      @Override
      protected String doInBackground(String... params) {
  
          String method = params[0];
          if (method.equals("getCityList")) {
              //String mobilenumber = params[1];
              String result = null;
  
              try {
                  URL reseturl = new URL(orderdetailsurl);
                  HttpURLConnection loginconnection = (HttpURLConnection) reseturl.openConnection();
                  loginconnection.setRequestMethod("POST");
                  loginconnection.setDoOutput(true);
                  loginconnection.setDoInput(true);
                  OutputStream loginos = loginconnection.getOutputStream();
                  BufferedWriter loginbw = new BufferedWriter(new OutputStreamWriter(loginos, "UTF-8"));
                  // loginbw.write(data);
                  loginbw.flush();
                  loginbw.close();
  
                  InputStream loginis = loginconnection.getInputStream();
                  BufferedReader loginbr = new BufferedReader(new InputStreamReader(loginis, "iso-8859-1"));
                  String response = "";
                  StringBuilder sb = new StringBuilder();
                  String line = "";
                  while ((line = loginbr.readLine()) != null) {
                      sb.append(line + "\n");
                  }
                  result = sb.toString();
              } catch (Exception e) {
                  // Oops
              } finally {
  
              }
              return result;
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(String result)
      {
          android.os.Debug.waitForDebugger();
          if (result == null) {
              final android.app.AlertDialog.Builder alertdialog = new android.app.AlertDialog.Builder(MainActivity.this);
              alertdialog.setMessage("Please check your Internet Connection!!!");
              alertdialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
  
                      Intent intent = getIntent();
                      finish();
                      startActivity(intent);
                  }
              });
  
              alertdialog.setTitle("Warning").create();
              alertdialog.show();
          }  else {
              getCityJSON = result;
              ShowCityList();
              //progressView.dismiss();
  
          }
      }
  }
  
  protected void ShowCityList() {
      try
      {
          JSONObject jsonObj = new JSONObject(getCityJSON);
          cityJSONArray = jsonObj.getJSONArray(TAG_RESULT);
          areas=new String[cityJSONArray.length()];
          for (int i = 0; i &lt; cityJSONArray.length(); i++) {
              JSONObject c = cityJSONArray.getJSONObject(i);
              String City=c.getString(TAG_CITY);
           areas[i]=City;
      }
  
          arrayAdapter = new ArrayAdapter&lt;String&gt;(
              this, android.R.layout.simple_dropdown_item_1line, areas);
          autocompletearea.setAdapter(arrayAdapter);
  
          autocompletearea.setThreshold(1);
  
          autocompletearea.setOnClickListener(new View.OnClickListener()
          {
              @Override
              public void onClick(View v) {
  
                  autocompletearea.showDropDown();
              }
          });
          autocompletearea.setOnFocusChangeListener(new View.OnFocusChangeListener()
          {
              @Override
              public void onFocusChange(View v, boolean hasFocus)
              {
                  autocompletearea.showDropDown();
              }
          });
  
  
          autocompletearea.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                  in.hideSoftInputFromWindow(view.getApplicationWindowToken(), 0);
                  String selection = (String) parent.getItemAtPosition(position);
                  for (int i = 0; i &lt; areas.length; i++) {
                      if (areas[i].equals(selection)) {
                          pos = i;
                          break;
                      }
                  }
  
                  System.out.println("Position " + pos); //check it now in Logcat
  
                  city=autocompletearea.getText().toString();
  
                  SharedPreferences.Editor editor = getPreferences(0).edit();
  
                  session.setcityselectedpreference(MainActivity.this,"cityselected","1");
                  int selectedPosition = parent.getSelectedItemPosition();
                  editor.putInt("spinnerSelection", pos);
                  editor.commit();
  
              }
          });
  
          SharedPreferences prefs = getPreferences(0);
          String cityselectedsession=session.getcityselectedPreference(this,"cityselected");
          if(cityselectedsession.equals(""))
          {
              autocompletearea.setText("");
          }
          else if(cityselectedsession.equals("1")) {
              autocompletearea.setText(areas[prefs.getInt("spinnerSelection", 0)]);
          }
      } catch (JSONException e) {
          e.printStackTrace();
      }
  
  }
  </code></pre>