I want to clear the application’s data when a user manually removes an account from the Accounts & sync section in the settings app.
I have my own implementation of AbstractAccountAuthenticator but there is no method to hook in the remove account process. Any hints?
I’ve been pondering on the same problem and here’s the “solution” I decided upon. It’s not what I’d call the “correct” solution but it’s the best I believe you can manage with the current API.
In my implementation of the
AbstractAccountAuthenticatorclass, I’ve overriden thegetAccountRemovalAllowedfunction as follows:There is a tiny chance that removal could fail AFTER you return from
getAccountRemovalAllowedbut it’s negligible (IMHO).As MisterSquonk suggested there is an Intent that you could listen for (
ACCOUNTS_CHANGED_INTENT) but, unfortunately, it’s broadcast when an account changes, and not just when an account is deleted.I don’t understand why this isn’t part of the SDK but maybe we’ve both missed something obvious! For now, I’m sticking with this approach as I need to delete some database tables of my own on account deletion.
I hope this helps.