UserManager.CreateUserCreationIntent Method

Definition

Returns an intent to create a user for the provided name and account name.

[Android.Runtime.Register("createUserCreationIntent", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/os/PersistableBundle;)Landroid/content/Intent;", "", ApiSince=24)]
public static Android.Content.Intent? CreateUserCreationIntent (string? userName, string? accountName, string? accountType, Android.OS.PersistableBundle? accountOptions);
[<Android.Runtime.Register("createUserCreationIntent", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/os/PersistableBundle;)Landroid/content/Intent;", "", ApiSince=24)>]
static member CreateUserCreationIntent : string * string * string * Android.OS.PersistableBundle -> Android.Content.Intent

Parameters

userName
String

Optional name to assign to the user.

accountName
String

Optional account name that will be used by the setup wizard to initialize the user.

accountType
String

Optional account type for the account to be created. This is required if the account name is specified.

accountOptions
PersistableBundle

Optional bundle of data to be passed in during account creation in the new user via AccountManager#addAccount(String, String, String[], Bundle, android.app.Activity, android.accounts.AccountManagerCallback, Handler).

Returns

An Intent that can be launched from an Activity.

Attributes

Remarks

Returns an intent to create a user for the provided name and account name. The name and account name will be used when the setup process for the new user is started.

The intent should be launched using startActivityForResult and the return result will indicate if the user consented to adding a new user and if the operation succeeded. Any errors in creating the user will be returned in the result code. If the user cancels the request, the return result will be Activity#RESULT_CANCELED. On success, the result code will be Activity#RESULT_OK.

Use #supportsMultipleUsers() to first check if the device supports this operation at all.

The new user is created but not initialized. After switching into the user for the first time, the preferred user name and account information are used by the setup process for that user.

This API should only be called if the current user is an #isAdminUser() admin user, as otherwise the returned intent will not be able to create a user.

Java documentation for android.os.UserManager.createUserCreationIntent(java.lang.String, java.lang.String, java.lang.String, android.os.PersistableBundle).

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