Android.Accounts.AccountManager.AddOnAccountsUpdatedListener Method
Adds an Android.Accounts.IOnAccountsUpdateListener to this instance of the Android.Accounts.AccountManager.

Syntax

[Android.Runtime.Register("addOnAccountsUpdatedListener", "(Landroid/accounts/OnAccountsUpdateListener;Landroid/os/Handler;Z)V", "GetAddOnAccountsUpdatedListener_Landroid_accounts_OnAccountsUpdateListener_Landroid_os_Handler_ZHandler")]
public virtual void AddOnAccountsUpdatedListener (IOnAccountsUpdateListener listener, Android.OS.Handler handler, bool updateImmediately)

Parameters

listener
The listener to send notifications to
handler
Android.OS.Handler identifying the thread to use for notifications, null for the main thread
updateImmediately
If true, the listener will be invoked (on the handler thread) right away with the current account list

Exceptions

TypeReason
Java.Lang.IllegalArgumentExceptionif listener is null
Java.Lang.IllegalStateExceptionif listener was already added

Remarks

Adds an Android.Accounts.IOnAccountsUpdateListener to this instance of the Android.Accounts.AccountManager. This listener will be notified whenever the list of accounts on the device changes.

As long as this listener is present, the AccountManager instance will not be garbage-collected, and neither will the Android.Content.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 Android.App.Activity.OnCreate(Android.OS.Bundle) and removed in Android.App.Activity.OnDestroy.

It is safe to call this method from the main thread.

This method requires the caller to hold the permission NoType:android/Manifest$permission;Href=../../../reference/android/Manifest.permission.html#GET_ACCOUNTS.

[Android Documentation]

Requirements

Namespace: Android.Accounts
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 5