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

杀马特。学长 韩版系。学妹 提交于 2019-12-11 14:46:23

问题


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());

回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/47712009/how-to-forcefully-remove-google-default-selected-account-in-gmail-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!