Does SyncAdapter get notified when AccountManager removes account?

后端 未结 3 1563
心在旅途
心在旅途 2020-12-30 14:46

So, my question restated is when you go to Settings -> Accounts & Sync and select the an account that was created that your SyncAdapter is syncing with a c

3条回答
  •  离开以前
    2020-12-30 15:22

    No, but your Authenticator does[1]. This method is called before the account is removed:

    AbstractAccountAuthenticator.getAccountRemovalAllowed(AccountAuthenticatorResponse, Account) 
    

    the Account param is the account being deleted - the default behaviour is to allow removal of the account:

    return super.getAccountRemovalAllowed(response, account); // returns Bundle[{booleanResult=true}]
    

    ..but I guess it's a hook that you can use to tidy things up or block the account being removed should you wish to.

    [1] - this is a dirty hack; please see Dandre's comment.

提交回复
热议问题