You can add an implementation of the AccountChangeListener
to listen for changes to existing accounts or for accounts being created.
Once an Account object is returned from one of the getter methods in AccountsManager
, its properties are not effected by calls made to updateAccount()
using another instance of the Account. To keep an Account instance up to date, add an implementation of AccountChangeListener
is passed to the listener when a change happens specifying which account has changed, and what type of change took place. For example, if an account has registered a change listener, the following method is called when an Account is changed:
To listen for account changes, perform the following steps:
Parent topic: Accounts framework
- Use the AccountsManagerFactory to access a singleton instance of the platform implementation of the AccountsManager interface.
- Add an AccountChangeListener to the account you want to monitor.
- To find out what change occurred after an event, call getEvent() to retrieve the AccountEvent, which contains the event details.
- When you no longer want to monitor an account, remove the listener.
The following Account changes can be monitored by the AccountChangeListener: Addition
of an Account to persistent store, Update of an Account in persistent store, or Removal of an Account from persistent store.