gpt4 book ai didi

android - AccountManager 删除了哪个账户

转载 作者:行者123 更新时间:2023-11-29 21:11:00 41 4
gpt4 key购买 nike

我知道 AccountManageraddOnAccountsUpdatedListener()可用于获取有关帐户列表更改的通知。如果发生此类事件,框架将调用提供的 OnAccountsUpdateListeneronAccountsUpdated()方法。但是该方法的参数只包含帐户列表。我怎么知道哪个帐户被用户删除了?提前致谢!

最佳答案

根据您尝试执行的操作,您可能会这样做:

private Set<Account> mAccountCache; // init & populated when the listener is registered

@Override
public void onAccountsUpdated(Account[] accounts) {
// This code assumes we're only interested in removed items.
final Set<Account> currentAccounts = new HashSet<Account>(Arrays.asList(accounts));
final Set<Account> removedAccounts = new HashSet<Account>(mAccountCache);
removedAccounts.removeAll(currentAccounts); // populated with Accounts that were removed.
}

关于android - AccountManager 删除了哪个账户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22859150/

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