如何在Gmail API中强制删除Google默认选定的帐户?

时间:2017-12-08 10:08:00

标签: android gmail gmail-api google-account

我正在尝试从Android中的应用程序注销时从gmail api中删除默认选定帐户。

这是GoogleAccountCredential函数建立的gmail帐户连接。

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

2 个答案:

答案 0 :(得分:0)

我也累了,但我找到了解决办法;如果从Gmail API中删除默认选定帐户后,Google帐户已经登录。按照这一步......

 SharedPreferences.Editor editor = getPreferences(Context.MODE_PRIVATE).edit();
 editor.putString(PREF_ACCOUNT_NAME, null);
 editor.commit(); 

更新特定关键字" PREF_ACCOUNT_NAME "的偏好设定值

〜感谢

答案 1 :(得分:-1)

Gmail API不提供和默认帐户选择方法,您可以在需要时调用此方法选择帐户

startActivityForResult(
        mCredential.newChooseAccountIntent(),
        REQUEST_ACCOUNT_PICKER);

请记住在注销时将null传递给mCredential