gpt4 book ai didi

android - 如何取消应用程序与谷歌驱动器帐户的链接

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:24:18 24 4
gpt4 key购买 nike

我正在通过 google play services - drive api 链接我的应用程序。工作正常,直到我尝试取消链接我的申请表用户的谷歌驱动器帐户。我找到了一种使用 Plus API 的方法;

mApi = new GoogleApiClient.Builder(context)
.addApi(Drive.API)
.addApi(Plus.API)
.addScope(Drive.SCOPE_APPFOLDER)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
...
...
Plus.AccountApi.clearDefaultAccount(mApi);
mApi.disconnect();

但这实际上对我帮助不大。当我将我的应用程序重新链接到谷歌驱动器时,没有显示帐户选择 Intent 。 (我的帐户没有激活 Google Plus 服务!)

是否有任何其他方法可以取消应用程序与 google-drive 的链接。我想知道为什么 Drive::DriveApi::clearDefaultAccount 不存在?

编辑:

好吧,作为解决方法;

mApi.clearDefaultAccountAndReconnect();
mApi.disconnect();

这将清除身份验证数据并且 mApi.disconnect() 不会让重新连接...我仍然想知道是否有任何优雅的解决方案...

最佳答案

如您所见,方法 clearDefaultAccount() 已弃用并替换为 clearDefaultAccountAndReconnect()

clearDefaultAccountAndReconnect() 方法会删除在 Google Play 服务中为您的应用设置的默认帐户。对 connect() 的后续调用将返回一个解析 Intent ,让用户选择一个不同的帐户。

如果用户选择相同的帐户,则不需要同意,因为应用程序的访问权限不会被撤销。还应为用户提供使用 revokeAccessAndDisconnect(GoogleApiClient) 撤销访问权限的选项。

您可以在链接上找到更多信息:https://developer.android.com/reference/com/google/android/gms/plus/Account.html

希望对您有所帮助。

关于android - 如何取消应用程序与谷歌驱动器帐户的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27551078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com