title: Dialog won't show up in the second time
body: <p>I've got a code that created a google document in google drive. When user gives incorrect credentials the application should pop up another dialog for the user to correct its credentials.The dialog doesn't show again once the <code>entry = docService.insert(feedUrl, entry);</code> throws <code>AuthenticationException</code>. The <code>loginDialog()</code> is first being called by the main activity, the rest is taken care by the application. Here's my code:</p>
  
  <pre><code>public void loginDialog(String error) {
  
          dialog = new Dialog(_context);
          dialog.setContentView(R.layout.login_dialog);
          dialog.setTitle("Enter your gmail account");
  
          dialog.show();
  
          Button saveLogin = (Button) dialog.findViewById(R.id.saveLogin);
          Button cancelled = (Button) dialog.findViewById(R.id.cancelLogin);
          final EditText userName = (EditText) dialog
                  .findViewById(R.id.userNameEditText);
          final EditText password = (EditText) dialog
                  .findViewById(R.id.passwordEditText);
          TextView errorField = (TextView) dialog
                  .findViewById(R.id.loginRegisterErrorTextView);
          errorField.setText(error);
  
          userName.setText(getUsername()); // if the username has been saved
                                              // getUserName()
                                              // will return the username,
                                              // otherwise it will return an empty
                                              // string.
  
          saveLogin.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  dialog.setCancelable(true);
                  USERNAME = userName.getText().toString();
                  PASSWORD = password.getText().toString();
                  saveUsername(USERNAME);
                  upload();
                  dialog.cancel();
              }
          });
          cancelled.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  dialog.setCancelable(true);
                  dialog.cancel();
  
              }
          });
      }
  
      private void upload() {
          SpreadSheetAsyncTask sprdSheetAsyncTsk = new SpreadSheetAsyncTask();
  
          sprdSheetAsyncTsk.execute();
  
      }
  
      public class SpreadSheetAsyncTask extends AsyncTask&lt;Void, Void, Void&gt; {
  
          private ProgressDialog mProgressDialog;
  
          @Override
          protected Void doInBackground(Void... params) {
              spreadSheetService = new SpreadsheetService("Salary_Calculator");
              docService = new DocsService("Salary_Calculator");
              try {
  
                  spreadSheetService.setUserCredentials(USERNAME, PASSWORD);
                  docService.setUserCredentials(USERNAME, PASSWORD);
  
                  URL feedUrl = new URL(
                          "https://docs.google.com/feeds/default/private/full/");
                  // URL tmpFeedUrl = new URL(
                  // "https://spreadsheets.google.com/feeds/worksheets/key/private/full");
  
                  DocumentEntry entry = new DocumentEntry();
  
                  Calendar timeRightNow = GregorianCalendar.getInstance();
  
                  entry.setTitle(new PlainTextConstruct(
                          "Salary Calculator Spreadsheet "
                                  + timeRightNow.get(Calendar.DAY_OF_MONTH) + "/"
                                  + (timeRightNow.get(Calendar.MONTH) + 1) + "/"
                                  + timeRightNow.get(Calendar.YEAR)));
  
                  // Category object = new Category("spreadsheet",
                  // "http://schemas.google.com/docs/2007#spreadsheet");
                  //
                  //
                  // entry.getCategories().add(object);                       
  
                  entry = docService.insert(feedUrl, entry);
  
              } catch (AuthenticationException e) {
                  cancel(true);
                  dialog.cancel();
                   mProgressDialog.dismiss();
                  loginDialog("Wrong username or password");
              } catch (IOException e) {
                  e.printStackTrace();
                  dialog.cancel();
                   mProgressDialog.dismiss();
                  loginDialog("Target server failed to respond with a valid HTTP response");
                  return null;
              } catch (ServiceException e) {
                  cancel(true);
                  dialog.cancel();
                   mProgressDialog.dismiss();
                  loginDialog("Service Error");
              } catch (Exception e) {
                  dialog.cancel();
                   mProgressDialog.dismiss();
                  loginDialog("Error");
              }
  
              return null;
          }
  </code></pre>