title: Android UI Thread Block when calling AsynchTask.get()
body: <p>My activity is a login page. When the user clicks, an asyncTask check in a database if credentials are good. During the task, I want to display a ProgressDialog but after clicking on the button, it stays pressed for 5 seconds and then my ProgressDialog quiclky shows up (less than 1 second) and the toast appears.</p>
  
  <p>There is my onClick function :</p>
  
  <pre><code>Button connect = (Button)findViewById(R.id.connectButton);
  final EditText loginED = (EditText) findViewById(R.id.login);
  final EditText passwordED = (EditText) findViewById(R.id.password);
  
  connect.setOnClickListener(new View.OnClickListener(){
  
      @Override
  public void onClick(View arg0) {
  
      String login = loginED.getText().toString();
      String password = passwordED.getText().toString();
      String[] params = {login, password};
  
      DoAsyncLogin doAsyncLogin = new DoAsyncLogin();
          try {
          String result = doAsyncLogin.execute(params).get();
          Toast.makeText(MainActivity.this, result, Toast.LENGTH_LONG).show();
      } catch (InterruptedException e) {
          e.printStackTrace();
      } catch (ExecutionException e) {
          e.printStackTrace();
      }
     }
  });
  </code></pre>
  
  <p>And my AsyncTask :</p>
  
  <pre><code>private class DoAsyncLogin extends AsyncTask&lt;String, Void, String&gt;
  {
  ProgressDialog connectionProgressDialog = new ProgressDialog(MainActivity.this);
  
  @Override
      protected String doInBackground(String... params) {
      return getLoginData(params);
  }
  
  protected void onPreExecute(){
  
      connectionProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
      connectionProgressDialog.setMessage("Logging in...");
      connectionProgressDialog.show();
  }
  
  protected void onPostExecute(String result)
  {
      connectionProgressDialog.dismiss();
  }
  }
  </code></pre>
  
  <p>Any ideas ?</p>
  
  <p>Thanks !</p>