title: Removing account from AccountManager doesn't send user to AccountAuthenticatorActivity
body: <p>I have an app that registers users using AccountManager and custom AccountAuthenticator.</p>
  
  <p>I need to implement the <code>Log Out</code> functionality.</p>
  
  <p>When user clicks the <code>Log Out</code> button, their account gets removed successfully, but the activity stays the same, the user doesn't get redirected to the <code>AccountAuthenticatorActivity</code>, although if I close the app and open it again, it will show the authentication screen (i.e. the account actually was removed).</p>
  
  <h3>My question:</h3>
  
  <p>Do I have to perform the redirection myself (using <code>finish(); startActivity(...);</code>) or the Authenticator and AccountManager should handle it for me (because I thought that if it is declared as a service, it should)? </p>
  
  <hr>
  
  <p>Maybe I have to implement some sort of account removal listener?</p>
  
  <p>Anyway, here's how I delete the account in <code>MainActivity</code>:</p>
  
  <pre><code>    private void performLogout() {
          Account[] accounts = accountManager.getAccountsByType(AccountGeneral.ACCOUNT_TYPE);
          if (accounts.length != 0) {    
              accountManager.clearPassword(accounts[0]);
              accountManager.invalidateAuthToken(AccountGeneral.ACCOUNT_TYPE,
                      accountManager.getAuthToken(accounts[0], AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS, null, true,
                              accountManagerFuture -&gt; {
                                  try {
                                      Log.d("invalidateAuthToken", accountManagerFuture.getResult().toString());
                                  } catch (android.accounts.OperationCanceledException | AuthenticatorException | IOException e) {
                                      e.printStackTrace();
                                  }
                              }, null).toString());
  
              if (Build.VERSION.SDK_INT &lt; 23) { // use deprecated method
                accountManager.removeAccount(accounts[0], accountManagerFuture -&gt; {
                    try {
                        if (accountManagerFuture.getResult()) {
                            Log.d("Deprecated ACCOUNT REMOVAL", "ACCOUNT  REMOVED");
  
                        }
                    } catch (android.accounts.OperationCanceledException | IOException | AuthenticatorException e) {
                        e.printStackTrace();
                    }
                }, null);
            } else {
                accountManager.removeAccount(accounts[0], this, accountManagerFuture -&gt; {
                    try {
                        if (accountManagerFuture.getResult() != null) {
                            Log.d("ACCOUNT REMOVAL", "ACCOUNT REMOVED");
                        }
                    } catch (android.accounts.OperationCanceledException | AuthenticatorException | IOException e) {
                        e.printStackTrace();
                    }
                }, null);
            }
          }
      }
  </code></pre>
  
  <p>BTW, when I click <code>Log Out</code>, I can see in the logs the following line:</p>
  
  <blockquote>
    <p>D/invalidateAuthToken: Bundle[{intent=Intent { cat=[2]
    cmp=discounty.com/.activities.LoginActivity (has extras) }}]</p>
  </blockquote>
  
  <p>so it seems that my <code>LoginActivity</code> (AccountAuthenticatorActivity) actually wants to appear but something prevents it from doing so.</p>
  
  <p>In my custom <code>AccountAuthenticator</code> I have this method implemented (and a couple of others responsible for account and token creation):</p>
  
  <pre><code>@Override
  public Bundle getAccountRemovalAllowed(AccountAuthenticatorResponse response, Account account) throws NetworkErrorException {
      Bundle bundle = new Bundle();
      boolean allowed = true;
      bundle.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, allowed);
      return bundle;
  }
  </code></pre>
  
  <p>and in my manifest I have the service declared the following way:</p>
  
  <pre><code>&lt;service
      android:name=".authenticator.DiscountyAuthenticationService"
      android:process=":auth"&gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.accounts.AccountAuthenticator" /&gt;
      &lt;/intent-filter&gt;
      &lt;meta-data android:name="android.accounts.AccountAuthenticator"
          android:resource="@xml/authenticator" /&gt;
  &lt;/service&gt;
  </code></pre>
  
  <hr>
  
  <p>So, do I have to redirect the users manually or I need to improve something in my code to make AccountManager handle the redirection for me?</p>