无法删除自己的自定义账户 [英] Not able to remove my own custom-account

查看:134
本文介绍了无法删除自己的自定义账户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have googled for this problem, but I did not find any solution.

我已经创建了自己的定制账户。当我试图以编程方式使用以下code删除的帐户,该帐户无法删除:

I have created my own Custom-Account. When I'm trying to remove the account programmatically using the following code, the account is not be removed:

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

甚至,当我尝试从设置中删除帐户,什么都没有发生。
当我卸载该应用程序的帐户只删除。

Even, when I try to remove the account from Setting, nothing happened. the account is removed only when I uninstall the application.

我应该怎么办?

推荐答案

您没有使用未来作为参数传递给 AccountManagerCallback&LT通过;布尔方式> #run

You are not using the Future passed as a parameter to the AccountManagerCallback<Boolean>#run method.

您应该提供回调作为第二个参数为:<一href=\"http://developer.android.com/reference/android/accounts/AccountManager.html#removeAccount%28android.accounts.Account,%20android.accounts.AccountManagerCallback%3Cjava.lang.Boolean%3E,%20android.os.Handler%29\"相对=nofollow> 公共AccountManagerFuture&LT;布尔&GT; removeAccount(账户账号,AccountManagerCallback&LT;布尔&GT;的回调,处理程序处理程序)

You should provide the callback as the second parameter to: 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线程上调用。这个例子没有为简洁起见提供机制。

You should be careful how you call future.getResult(). It should not be called on the main UI thread. This example does not provide that mechanism for brevity.

这篇关于无法删除自己的自定义账户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆