androidbroadcastreceiveraccountaccountmanagerandroid-account

How to get notified when an account is add to or remove from device?


I want to set a BroadcastReceiver to get notified when an account is removed from the device. What IntentFilter should I use in my BroadcastReceiver. I couldn't find any related intent.

Thanks


Solution

  • With the help of this question, I found that there is an intent called: LOGIN_ACCOUNTS_CHANGED_ACTION. Here is the documentation:

    Action sent as a broadcast Intent by the AccountsService when accounts are added, accounts are removed, or an account's credentials (saved password, etc) are changed.

    It worked correctly. Also there is another option that is using addOnAccountsUpdatedListener