2014-04-04 3 views
1

나는 AccountManager 님의 addOnAccountsUpdatedListener()을 사용하여 계정 목록 변경에 대한 알림을받을 수 있음을 알고 있습니다. 이러한 종류의 이벤트가 발생하면 프레임 워크는 제공된 OnAccountsUpdateListeneronAccountsUpdated() 메서드를 호출합니다. 그러나 메소드의 인수에는 계정 목록 만 포함됩니다. 사용자가 어떤 계정을 삭제했는지 어떻게 알 수 있습니까? 미리 감사드립니다!계정이 삭제 된 AccountManager

답변

2

당신이 뭘하려는 건지에 따라, 당신이 멀리 얻을 수 있습니다 :

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. 
} 
+1

나는이 솔루션에 대한 생각,하지만 난 다른 방법이 희망했다. 감사! – WonderCsabo

관련 문제