public class

AccountManager

extends Object
java.lang.Object
   ↳ com.datalogic.device.account.AccountManager

Class Overview

AccountManager provides APIs for managing user accounts in the system.

Supports operations for retrieving, removing accounts, and listening to account updates.

Note: The constructor will throw a DeviceException if the AccountManager service is not available on this device.

Summary

Nested Classes
interface AccountManager.AccountUpdateListener Listener interface for receiving notifications about account updates in the system. 
Constants
String GOOGLE_ACCOUNT_TYPE Google account type constant used to identify Google accounts in the system.
Public Constructors
AccountManager()
Creates a new instance of AccountManager.
Public Methods
void registerAccountUpdateListener(AccountManager.AccountUpdateListener listener)
Registers a listener to receive notifications when accounts are updated in the system.
void removeAccount(Account account)
Removes a specific account from the system.
void removeAllAccounts()
Removes all accounts from the system.
void removeAllAccountsWithType(String type)
Removes all accounts of a specified type from the system.
Account[] retrieveAllAccounts()
Retrieves all accounts in the system regardless of type.
Account[] retrieveAllAccountsWithType(String type)
Retrieves all accounts that match the specified account type.
void unregisterAccountUpdateListener(AccountManager.AccountUpdateListener listener)
Unregisters a previously registered listener from account update notifications.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String GOOGLE_ACCOUNT_TYPE

Added in revision 49

Google account type constant used to identify Google accounts in the system.

Constant Value: "com.google"

Public Constructors

public AccountManager ()

Added in revision 49

Creates a new instance of AccountManager.

This constructor connects to the underlying AccountManager service.

Throws
DeviceException if the AccountManager service is not available on this device

Public Methods

public void registerAccountUpdateListener (AccountManager.AccountUpdateListener listener)

Added in revision 49

Registers a listener to receive notifications when accounts are updated in the system.

Multiple listeners can be registered. The listener will be added to the internal list, and when the first listener is registered, the connection to the service is established. If registration with the service fails, the error is logged but the listener is still added to the local list.

Parameters
listener The AccountManager.AccountUpdateListener callback to register for account update events. Must not be null.
Throws
IllegalArgumentException if the listener is null

public void removeAccount (Account account)

Added in revision 49

Removes a specific account from the system.

Parameters
account The Account to remove from the system. Should not be null.
Throws
RuntimeException if the AccountManager service is not available, or if an error occurs during account removal

public void removeAllAccounts ()

Added in revision 49

Removes all accounts from the system.

Throws
RuntimeException if the AccountManager service is not available, or if an error occurs during account removal

public void removeAllAccountsWithType (String type)

Added in revision 49

Removes all accounts of a specified type from the system.

Parameters
type The account type to remove (e.g., GOOGLE_ACCOUNT_TYPE). Should not be null.
Throws
RuntimeException if the AccountManager service is not available, or if an error occurs during account removal

public Account[] retrieveAllAccounts ()

Added in revision 49

Retrieves all accounts in the system regardless of type.

Returns
  • An array of all Account objects in the system.
Throws
RuntimeException if the AccountManager service is not available, or if an error occurs during account retrieval

public Account[] retrieveAllAccountsWithType (String type)

Added in revision 49

Retrieves all accounts that match the specified account type.

Parameters
type The account type to filter by (e.g., GOOGLE_ACCOUNT_TYPE). Must not be null.
Returns
  • An array of Account objects matching the specified type.
Throws
RuntimeException if the AccountManager service is not available, or if an error occurs during account retrieval

public void unregisterAccountUpdateListener (AccountManager.AccountUpdateListener listener)

Added in revision 49

Unregisters a previously registered listener from account update notifications.

If the listener was not previously registered, this method logs a warning and returns. When the last listener is unregistered, the connection to the service is removed. If unregistration with the service fails, the error is logged but the listener is still removed from the local list.

Parameters
listener The AccountManager.AccountUpdateListener callback to unregister. Must not be null.
Throws
IllegalArgumentException if the listener is null