CreateEntry


@RequiresApi(value = 23)
class CreateEntry


An entry to be shown on the selector during a create flow initiated when an app calls CredentialManager.createCredential

A CreateEntry points to a location such as an account, or a group where the credential can be registered. When user selects this entry, the corresponding PendingIntent is fired, and the credential creation can be completed.

Summary

Nested types

A builder for CreateEntry

Public companion functions

CreateEntry?

Converts a framework android.service.credentials.CreateEntry class to a Jetpack CreateEntry class

Public constructors

CreateEntry(
    accountName: CharSequence,
    pendingIntent: PendingIntent,
    description: CharSequence?,
    lastUsedTime: Instant?,
    icon: Icon?,
    passwordCredentialCount: Int?,
    publicKeyCredentialCount: Int?,
    totalCredentialCount: Int?,
    isAutoSelectAllowed: Boolean
)
@RequiresApi
CreateEntry(
    accountName: CharSequence,
    pendingIntent: PendingIntent,
    description: CharSequence?,
    lastUsedTime: Instant?,
    icon: Icon?,
    passwordCredentialCount: Int?,
    publicKeyCredentialCount: Int?,
    totalCredentialCount: Int?,
    isAutoSelectAllowed: Boolean,
    biometricPromptData: BiometricPromptData?
)

Public functions

Int?

Returns the no. of password type credentials that the provider with this entry has.

Int?

Returns the no. of public key type credentials that the provider with this entry has.

Int?

Returns the no. of total credentials that the provider with this entry has.

Public properties

CharSequence

the name of the account where the credential will be saved

BiometricPromptData?

the data that is set optionally to utilize a credential manager flow that directly handles the biometric verification and presents back the response; set to null by default, so if not opted in, the embedded biometric prompt flow will not show

CharSequence?

the localized description shown on UI about where the credential is stored

Icon?

the icon to be displayed with this entry on the UI, must be created using Icon.createWithResource when possible, and especially not with Icon.createWithBitmap as the latter consumes more memory and may cause undefined behavior due to memory implications on internal transactions

Boolean

whether this entry should be auto selected if it is the only entry on the selector

Instant?

the last time the account underlying this entry was used by the user, distinguishable up to the milli second mark only such that if two entries have the same millisecond precision, they will be considered to have been used at the same time

PendingIntent

the PendingIntent that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request, and NOT with flag PendingIntent.FLAG_ONE_SHOT as it can be invoked multiple times

Public companion functions

fromCreateEntry

Added in 1.5.0-beta01
fun fromCreateEntry(createEntry: CreateEntry): CreateEntry?

Converts a framework android.service.credentials.CreateEntry class to a Jetpack CreateEntry class

Note that this API is not needed in a general credential creation flow that is implemented using this jetpack library, where you are only required to construct an instance of CreateEntry to populate the BeginCreateCredentialResponse.

Parameters
createEntry: CreateEntry

the instance of framework class to be converted

Public constructors

CreateEntry

Added in 1.2.0
CreateEntry(
    accountName: CharSequence,
    pendingIntent: PendingIntent,
    description: CharSequence? = null,
    lastUsedTime: Instant? = null,
    icon: Icon? = null,
    passwordCredentialCount: Int? = null,
    publicKeyCredentialCount: Int? = null,
    totalCredentialCount: Int? = null,
    isAutoSelectAllowed: Boolean = false
)
Parameters
accountName: CharSequence

the name of the account where the credential will be saved

pendingIntent: PendingIntent

the PendingIntent that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request, and NOT with flag PendingIntent.FLAG_ONE_SHOT as it can be invoked multiple times

description: CharSequence? = null

the localized description shown on UI about where the credential is stored

lastUsedTime: Instant? = null

the last time the account underlying this entry was used by the user, distinguishable up to the milli second mark only such that if two entries have the same millisecond precision, they will be considered to have been used at the same time

icon: Icon? = null

the icon to be displayed with this entry on the UI, must be created using Icon.createWithResource when possible, and especially not with Icon.createWithBitmap as the latter consumes more memory and may cause undefined behavior due to memory implications on internal transactions

passwordCredentialCount: Int? = null

the no. of password credentials contained by the provider

publicKeyCredentialCount: Int? = null

the no. of public key credentials contained by the provider

totalCredentialCount: Int? = null

the total no. of credentials contained by the provider

isAutoSelectAllowed: Boolean = false

whether this entry should be auto selected if it is the only entry on the selector

Throws
kotlin.IllegalArgumentException

If accountName is empty, or if description is longer than 300 characters (important: make sure your descriptions across all locales are within this limit)

kotlin.NullPointerException

If accountName or pendingIntent is null

CreateEntry

Added in 1.5.0-beta01
@RequiresApi
CreateEntry(
    accountName: CharSequence,
    pendingIntent: PendingIntent,
    description: CharSequence? = null,
    lastUsedTime: Instant? = null,
    icon: Icon? = null,
    passwordCredentialCount: Int? = null,
    publicKeyCredentialCount: Int? = null,
    totalCredentialCount: Int? = null,
    isAutoSelectAllowed: Boolean = false,
    biometricPromptData: BiometricPromptData? = null
)
Parameters
accountName: CharSequence

the name of the account where the credential will be saved

pendingIntent: PendingIntent

the PendingIntent that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request, and NOT with flag PendingIntent.FLAG_ONE_SHOT as it can be invoked multiple times

description: CharSequence? = null

the localized description shown on UI about where the credential is stored

lastUsedTime: Instant? = null

the last time the account underlying this entry was used by the user, distinguishable up to the milli second mark only such that if two entries have the same millisecond precision, they will be considered to have been used at the same time

icon: Icon? = null

the icon to be displayed with this entry on the UI, must be created using Icon.createWithResource when possible, and especially not with Icon.createWithBitmap as the latter consumes more memory and may cause undefined behavior due to memory implications on internal transactions

passwordCredentialCount: Int? = null

the no. of password credentials contained by the provider

publicKeyCredentialCount: Int? = null

the no. of public key credentials contained by the provider

totalCredentialCount: Int? = null

the total no. of credentials contained by the provider

isAutoSelectAllowed: Boolean = false

whether this entry should be auto selected if it is the only entry on the selector

biometricPromptData: BiometricPromptData? = null

the data that is set optionally to utilize a credential manager flow that directly handles the biometric verification and presents back the response; set to null by default, so if not opted in, the embedded biometric prompt flow will not show

Throws
kotlin.IllegalArgumentException

If accountName is empty, or if description is longer than 300 characters (important: make sure your descriptions across all locales are within this limit)

kotlin.NullPointerException

If accountName or pendingIntent is null

Public functions

getPasswordCredentialCount

Added in 1.2.0
fun getPasswordCredentialCount(): Int?

Returns the no. of password type credentials that the provider with this entry has.

getPublicKeyCredentialCount

Added in 1.2.0
fun getPublicKeyCredentialCount(): Int?

Returns the no. of public key type credentials that the provider with this entry has.

getTotalCredentialCount

Added in 1.2.0
fun getTotalCredentialCount(): Int?

Returns the no. of total credentials that the provider with this entry has.

This total count is not necessarily equal to the sum of getPasswordCredentialCount and getPublicKeyCredentialCount.

Public properties

accountName

Added in 1.2.0
val accountNameCharSequence

the name of the account where the credential will be saved

biometricPromptData

Added in 1.5.0-beta01
val biometricPromptDataBiometricPromptData?

the data that is set optionally to utilize a credential manager flow that directly handles the biometric verification and presents back the response; set to null by default, so if not opted in, the embedded biometric prompt flow will not show

description

Added in 1.2.0
val descriptionCharSequence?

the localized description shown on UI about where the credential is stored

icon

Added in 1.2.0
val iconIcon?

the icon to be displayed with this entry on the UI, must be created using Icon.createWithResource when possible, and especially not with Icon.createWithBitmap as the latter consumes more memory and may cause undefined behavior due to memory implications on internal transactions

isAutoSelectAllowed

Added in 1.2.0
val isAutoSelectAllowedBoolean

whether this entry should be auto selected if it is the only entry on the selector

lastUsedTime

Added in 1.2.0
val lastUsedTimeInstant?

the last time the account underlying this entry was used by the user, distinguishable up to the milli second mark only such that if two entries have the same millisecond precision, they will be considered to have been used at the same time

pendingIntent

Added in 1.2.0
val pendingIntentPendingIntent

the PendingIntent that will get invoked when the user selects this entry, must be created with a unique request code per entry, with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request, and NOT with flag PendingIntent.FLAG_ONE_SHOT as it can be invoked multiple times