Search code examples
androidgmailgmail-apigoogle-account

How to forcefully remove Google default selected Account in Gmail API?


I am trying to remove default selected account from gmail api when logout from app in android.

this is GoogleAccountCredential function to establish connection of gmail account.

GoogleAccountCredential  mCredential = GoogleAccountCredential.usingOAuth2(
                getApplicationContext(), Arrays.asList(AppController.SCOPES))
                .setBackOff(new ExponentialBackOff());

Solution

  • Gmail API doesn't Provide And default account select method you can just call this method to select account when required

    startActivityForResult(
            mCredential.newChooseAccountIntent(),
            REQUEST_ACCOUNT_PICKER);
    

    just remember to pass null to mCredential when logout