共用方式為


AccountManager.AddAccountExplicitly Method

Definition

Overloads

AddAccountExplicitly(Account, String, Bundle)

Adds an account directly to the AccountManager.

AddAccountExplicitly(Account, String, Bundle, IDictionary<String,Integer>)

Adds an account directly to the AccountManager.

AddAccountExplicitly(Account, String, Bundle)

Adds an account directly to the AccountManager.

[Android.Runtime.Register("addAccountExplicitly", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;)Z", "GetAddAccountExplicitly_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_Handler")]
[Android.Runtime.RequiresPermission("android.permission.AUTHENTICATE_ACCOUNTS")]
public virtual bool AddAccountExplicitly (Android.Accounts.Account? account, string? password, Android.OS.Bundle? userdata);
[<Android.Runtime.Register("addAccountExplicitly", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;)Z", "GetAddAccountExplicitly_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_Handler")>]
[<Android.Runtime.RequiresPermission("android.permission.AUTHENTICATE_ACCOUNTS")>]
abstract member AddAccountExplicitly : Android.Accounts.Account * string * Android.OS.Bundle -> bool
override this.AddAccountExplicitly : Android.Accounts.Account * string * Android.OS.Bundle -> bool

Parameters

account
Account

The Account to add

password
String

The password to associate with the account, null for none

userdata
Bundle

String values to use for the account's userdata, null for none

Returns

True if the account was successfully added, false if the account already exists, the account is null, the user is locked, or another error occurs.

Attributes

Remarks

Adds an account directly to the AccountManager. Normally used by sign-up wizards associated with authenticators, not directly by applications.

Calling this method does not update the last authenticated timestamp, referred by #KEY_LAST_AUTHENTICATED_TIME. To update it, call #notifyAccountAuthenticated(Account) after getting success. However, if this method is called when it is triggered by addAccount() or addAccountAsUser() or similar functions, then there is no need to update timestamp manually as it is updated automatically by framework on successful completion of the mentioned functions.

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

This method requires the caller to have a signature match with the authenticator that owns the specified account.

<b>NOTE:</b> If targeting your app to work on API level 22 and before, AUTHENTICATE_ACCOUNTS permission is needed for those platforms. See docs for this function in API level 22.

Java documentation for android.accounts.AccountManager.addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle).

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

AddAccountExplicitly(Account, String, Bundle, IDictionary<String,Integer>)

Adds an account directly to the AccountManager.

[Android.Runtime.Register("addAccountExplicitly", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;Ljava/util/Map;)Z", "GetAddAccountExplicitly_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_Ljava_util_Map_Handler", ApiSince=26)]
public virtual bool AddAccountExplicitly (Android.Accounts.Account? account, string? password, Android.OS.Bundle? extras, System.Collections.Generic.IDictionary<string,Java.Lang.Integer>? visibility);
[<Android.Runtime.Register("addAccountExplicitly", "(Landroid/accounts/Account;Ljava/lang/String;Landroid/os/Bundle;Ljava/util/Map;)Z", "GetAddAccountExplicitly_Landroid_accounts_Account_Ljava_lang_String_Landroid_os_Bundle_Ljava_util_Map_Handler", ApiSince=26)>]
abstract member AddAccountExplicitly : Android.Accounts.Account * string * Android.OS.Bundle * System.Collections.Generic.IDictionary<string, Java.Lang.Integer> -> bool
override this.AddAccountExplicitly : Android.Accounts.Account * string * Android.OS.Bundle * System.Collections.Generic.IDictionary<string, Java.Lang.Integer> -> bool

Parameters

account
Account

The Account to add

password
String

The password to associate with the account, null for none

extras
Bundle

String values to use for the account's userdata, null for none

visibility
IDictionary<String,Integer>

Map from packageName to visibility values which will be set before account is added. See #getAccountVisibility for possible values. Declaring package visibility needs for package names in the map is needed, if the caller is targeting API level 34 and above.

Returns

True if the account was successfully added, false if the account already exists, the account is null, or another error occurs.

Attributes

Remarks

Adds an account directly to the AccountManager. Additionally it specifies Account visibility for given list of packages.

Normally used by sign-up wizards associated with authenticators, not directly by applications.

Calling this method does not update the last authenticated timestamp, referred by #KEY_LAST_AUTHENTICATED_TIME. To update it, call #notifyAccountAuthenticated(Account) after getting success.

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

This method requires the caller to have a signature match with the authenticator that owns the specified account.

Java documentation for android.accounts.AccountManager.addAccountExplicitly(android.accounts.Account, java.lang.String, android.os.Bundle, java.util.Map<java.lang.String, java.lang.Integer>).

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