AccountManager.AddOnAccountsUpdatedListener Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddOnAccountsUpdatedListener(IOnAccountsUpdateListener, Handler, Boolean) |
Adds an |
AddOnAccountsUpdatedListener(IOnAccountsUpdateListener, Handler, Boolean, String[]) |
Adds an |
AddOnAccountsUpdatedListener(IOnAccountsUpdateListener, Handler, Boolean)
Adds an OnAccountsUpdateListener
to this instance of the AccountManager
.
[Android.Runtime.Register("addOnAccountsUpdatedListener", "(Landroid/accounts/OnAccountsUpdateListener;Landroid/os/Handler;Z)V", "GetAddOnAccountsUpdatedListener_Landroid_accounts_OnAccountsUpdateListener_Landroid_os_Handler_ZHandler")]
[Android.Runtime.RequiresPermission("android.permission.GET_ACCOUNTS")]
public virtual void AddOnAccountsUpdatedListener (Android.Accounts.IOnAccountsUpdateListener? listener, Android.OS.Handler? handler, bool updateImmediately);
[<Android.Runtime.Register("addOnAccountsUpdatedListener", "(Landroid/accounts/OnAccountsUpdateListener;Landroid/os/Handler;Z)V", "GetAddOnAccountsUpdatedListener_Landroid_accounts_OnAccountsUpdateListener_Landroid_os_Handler_ZHandler")>]
[<Android.Runtime.RequiresPermission("android.permission.GET_ACCOUNTS")>]
abstract member AddOnAccountsUpdatedListener : Android.Accounts.IOnAccountsUpdateListener * Android.OS.Handler * bool -> unit
override this.AddOnAccountsUpdatedListener : Android.Accounts.IOnAccountsUpdateListener * Android.OS.Handler * bool -> unit
Parameters
- listener
- IOnAccountsUpdateListener
The listener to send notifications to
- updateImmediately
- Boolean
If true, the listener will be invoked (on the handler thread) right away with the current account list
- Attributes
Exceptions
if listener is null
if listener was already added
Remarks
Adds an OnAccountsUpdateListener
to this instance of the AccountManager
. This listener will be notified whenever user or AbstractAccountAuthenticator made changes to accounts of any type related to the caller. This method is equivalent to addOnAccountsUpdatedListener(listener, handler, updateImmediately, null)
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
AddOnAccountsUpdatedListener(IOnAccountsUpdateListener, Handler, Boolean, String[])
Adds an OnAccountsUpdateListener
to this instance of the AccountManager
.
[Android.Runtime.Register("addOnAccountsUpdatedListener", "(Landroid/accounts/OnAccountsUpdateListener;Landroid/os/Handler;Z[Ljava/lang/String;)V", "GetAddOnAccountsUpdatedListener_Landroid_accounts_OnAccountsUpdateListener_Landroid_os_Handler_ZarrayLjava_lang_String_Handler", ApiSince=26)]
public virtual void AddOnAccountsUpdatedListener (Android.Accounts.IOnAccountsUpdateListener? listener, Android.OS.Handler? handler, bool updateImmediately, string[]? accountTypes);
[<Android.Runtime.Register("addOnAccountsUpdatedListener", "(Landroid/accounts/OnAccountsUpdateListener;Landroid/os/Handler;Z[Ljava/lang/String;)V", "GetAddOnAccountsUpdatedListener_Landroid_accounts_OnAccountsUpdateListener_Landroid_os_Handler_ZarrayLjava_lang_String_Handler", ApiSince=26)>]
abstract member AddOnAccountsUpdatedListener : Android.Accounts.IOnAccountsUpdateListener * Android.OS.Handler * bool * string[] -> unit
override this.AddOnAccountsUpdatedListener : Android.Accounts.IOnAccountsUpdateListener * Android.OS.Handler * bool * string[] -> unit
Parameters
- listener
- IOnAccountsUpdateListener
The listener to send notifications to
- handler
- Handler
Handler
identifying the thread to use for notifications, null for the
main thread
- updateImmediately
- Boolean
If true, the listener will be invoked (on the handler thread) right away with the current account list
- accountTypes
- String[]
If set, only changes to accounts of given types will be reported.
- Attributes
Remarks
Adds an OnAccountsUpdateListener
to this instance of the AccountManager
. This listener will be notified whenever user or AbstractAccountAuthenticator made changes to accounts of given types related to the caller - either list of accounts returned by #getAccounts()
was changed, or new account was added for which user can grant access to the caller.
As long as this listener is present, the AccountManager instance will not be garbage-collected, and neither will the Context
used to retrieve it, which may be a large Activity instance. To avoid memory leaks, you must remove this listener before then. Normally listeners are added in an Activity or Service's Activity#onCreate
and removed in Activity#onDestroy
.
It is safe to call this method from the main thread.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.