title: Android: How to close foreground activity from active activity?
body: <p>I created an application which is asynchronously communicating with the server. When the application makes a server request a new dialog (activity) with "loading" notification is created. The main activity implements methods for handling server responses and I would like to close the foreground activity when the main activity receives the answer from the server.</p>
  
  <p>Notification dialog is created the following way:</p>
  
  <pre><code> private void showServerRequestDialog(String actionLabel){
      Intent intent = new Intent(this, DlgServerRequest.class);
      intent.putExtra(SERVER_REQUEST_ACTION, actionLabel);
      startActivity(intent);
  
  }
  </code></pre>
  
  <p>so when the user tries to authenticate the following method is called:</p>
  
  <pre><code>private void authenticateUser(String IMEI, String username, String password){
      mEncoderConnection.authenticateRequest(IMEI, username, password);
      showServerRequestDialog("Authenticating...");
  }
  </code></pre>
  
  <p>and onAuthenticateResponse handles authentication response:</p>
  
  <pre><code>public void onAuthenticateResponse(AuthenticateResponse pkg) {
      //code for response handling
      //TODO: close ServerRequestDialog
      }
  }
  </code></pre>
  
  <p>I would appreciate if anyone could suggest a way to close the notification dialog (DlgServerRequest) when the onAuthenticateUser() is executed.</p>