AccountManager.GetAccountsByType(String) Method

Definition

Lists all accounts of particular type visible to the caller.

[Android.Runtime.Register("getAccountsByType", "(Ljava/lang/String;)[Landroid/accounts/Account;", "GetGetAccountsByType_Ljava_lang_String_Handler")]
[Android.Runtime.RequiresPermission("android.permission.GET_ACCOUNTS")]
public virtual Android.Accounts.Account[] GetAccountsByType (string? type);
[<Android.Runtime.Register("getAccountsByType", "(Ljava/lang/String;)[Landroid/accounts/Account;", "GetGetAccountsByType_Ljava_lang_String_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.GET_ACCOUNTS")>]
abstract member GetAccountsByType : string -> Android.Accounts.Account[]
override this.GetAccountsByType : string -> Android.Accounts.Account[]

Parameters

type
String

The type of accounts to return, null to retrieve all accounts

Returns

An array of Account, one per matching account. Empty (never null) if no accounts of the specified type have been added.

Attributes

Remarks

Lists all accounts of particular type visible to the caller. These accounts may be visible because the user granted access to the account, or the AbstractAccountAuthenticator managing the account did so or because the client shares a signature with the managing AbstractAccountAuthenticator.

The account type is a string token corresponding to the authenticator and useful domain of the account. For example, there are types corresponding to Google and Facebook. The exact string token to use will be published somewhere associated with the authenticator in question.

<div class="caution">

<b>Caution: </b>This method returns personal and sensitive user data. If your app accesses, collects, uses, or shares personal and sensitive data, you must clearly disclose that fact to users. For apps published on Google Play, policies protecting user data require that you do the following:

<ul> <li>Disclose to the user how your app accesses, collects, uses, or shares personal and sensitive data. Learn more about acceptable disclosure and consent.</li> <li>Provide a privacy policy that describes your use of this data on- and off-device.</li> </ul>

To learn more, visit the Google Play Policy regarding user data.

</div>

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

Caller targeting API level android.os.Build.VERSION_CODES#O and above, will get list of accounts made visible to it by user (see #newChooseAccountIntent(Account, List, String[], String, String, String[], Bundle)) or AbstractAccountAuthenticator using #setAccountVisibility. android.Manifest.permission#GET_ACCOUNTS permission is not used.

Caller targeting API level below android.os.Build.VERSION_CODES#O that have not been granted the android.Manifest.permission#GET_ACCOUNTS permission, will only see those accounts managed by AbstractAccountAuthenticators whose signature matches the client.

<b>NOTE:</b> If targeting your app to work on API level android.os.Build.VERSION_CODES#LOLLIPOP_MR1 and before, android.Manifest.permission#GET_ACCOUNTS permission is needed for those platforms, irrespective of uid or signature match. See docs for this function in API level android.os.Build.VERSION_CODES#LOLLIPOP_MR1.

Java documentation for android.accounts.AccountManager.getAccountsByType(java.lang.String).

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