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());
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
I was tired also, but I have found the solution; If google account is already login after remove default selected account from Gmail API. follow this step...
SharedPreferences.Editor editor = getPreferences(Context.MODE_PRIVATE).edit();
editor.putString(PREF_ACCOUNT_NAME, null);
editor.commit();
update the value of preferences from particular Key "PREF_ACCOUNT_NAME"
~Thanks