diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java index 1d9e3bb4b4bb0..a9db2f610e608 100644 --- a/core/java/android/accounts/AccountManager.java +++ b/core/java/android/accounts/AccountManager.java @@ -1916,12 +1916,16 @@ public class AccountManager { handler.post(new Runnable() { @Override public void run() { - try { - listener.onAccountsUpdated(accountsCopy); - } catch (SQLException e) { - // Better luck next time. If the problem was disk-full, - // the STORAGE_OK intent will re-trigger the update. - Log.e(TAG, "Can't update accounts", e); + synchronized (mAccountsUpdatedListeners) { + try { + if (mAccountsUpdatedListeners.containsKey(listener)) { + listener.onAccountsUpdated(accountsCopy); + } + } catch (SQLException e) { + // Better luck next time. If the problem was disk-full, + // the STORAGE_OK intent will re-trigger the update. + Log.e(TAG, "Can't update accounts", e); + } } } });