gpt4 book ai didi

android - 无法删除我自己的自定义帐户

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

我用谷歌搜索了这个问题,但没有找到任何解决方案。

我已经创建了自己的自定义帐户。当我尝试使用以下代码以编程方式删除帐户时,该帐户不会被删除:

Account systemAccount = new Account(mainAccount.getDisplayName(), 
getResources().getString(R.string.account_type));
AccountManager.get(Accounts.this).removeAccount(systemAccount, null, null);

甚至,当我尝试从“设置”中删除帐户时,也没有任何反应。仅当我卸载应用程序时,该帐户才会被删除。

我该怎么办?

最佳答案

您没有使用 Future作为参数传递给 AccountManagerCallback<Boolean>#run方法。

您应该将回调作为第二个参数提供给: public AccountManagerFuture<Boolean> removeAccount (Account account, AccountManagerCallback<Boolean> callback, Handler handler)

myAccountManager.removeAccount(myAccount, new AccountManagerCallback<Boolean>() {
@Override
public void run(AccountManagerFuture<Boolean> future) {
// This is the line that actually starts the call to remove the account.
boolean wasAccountDeleted = future.getResult();
}
}, null);

你应该小心你如何称呼future.getResult() .不应在主 UI 线程上调用它。为简洁起见,此示例未提供该机制。

关于android - 无法删除我自己的自定义帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15358271/

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