PublicKeyCredentialEntry


@RequiresApi(value = 23)
class PublicKeyCredentialEntry : CredentialEntry


A public key credential entry that is displayed on the account selector UI. This entry denotes that a credential of type PublicKeyCredential.TYPE_PUBLIC_KEY_CREDENTIAL is available for the user to select.

Once this entry is selected, the corresponding pendingIntent will be invoked. The provider can then show any activity they wish to. Before finishing the activity, provider must set the final androidx.credentials.GetCredentialResponse through the PendingIntentHandler.setGetCredentialResponse helper API.

See also
CredentialEntry

Summary

Public companion functions

PublicKeyCredentialEntry?

Converts a framework android.service.credentials.CredentialEntry class to a Jetpack PublicKeyCredentialEntry class

Public constructors

PublicKeyCredentialEntry(
    context: Context,
    username: CharSequence,
    pendingIntent: PendingIntent,
    beginGetPublicKeyCredentialOption: BeginGetPublicKeyCredentialOption,
    displayName: CharSequence?,
    lastUsedTime: Instant?,
    icon: Icon,
    isAutoSelectAllowed: Boolean,
    isDefaultIconPreferredAsSingleProvider: Boolean
)
@RequiresApi
PublicKeyCredentialEntry(
    context: Context,
    username: CharSequence,
    pendingIntent: PendingIntent,
    beginGetPublicKeyCredentialOption: BeginGetPublicKeyCredentialOption,
    displayName: CharSequence?,
    lastUsedTime: Instant?,
    icon: Icon,
    isAutoSelectAllowed: Boolean,
    isDefaultIconPreferredAsSingleProvider: Boolean,
    biometricPromptData: BiometricPromptData?
)

Public properties

CharSequence?

the displayName of the account holding the public key credential

Boolean

whether this entry was created without a custom icon and hence contains a default icon set by the library, only to be used in Android API levels >= 28

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; defaulted to a fallback public key credential icon if not provided

Boolean
Boolean

whether the beginGetCredentialOption request for which this entry was created allows this entry to be auto-selected

Instant?

the last used time of this entry.

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

CharSequence
CharSequence

the username of the account holding the public key credential

Inherited properties

From androidx.credentials.provider.CredentialEntry
CharSequence?

the user visible affiliated domain, a CharSequence representation of a web domain or an app package name that the given credential in this entry is associated with when it is different from the requesting entity, default null

BeginGetCredentialOption

the option from the original BeginGetCredentialRequest, for which this credential entry is being added

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

an ID used for deduplication or to group entries during display

Boolean

when set to true, the UI prefers to render the default credential type icon when you are the only available provider; see individual subclasses for these default icons (e.g. for PublicKeyCredentialEntry, it is based on R.drawable.ic_password)

Public companion functions

fromCredentialEntry

Added in 1.5.0-beta01
fun fromCredentialEntry(credentialEntry: CredentialEntry): PublicKeyCredentialEntry?

Converts a framework android.service.credentials.CredentialEntry class to a Jetpack PublicKeyCredentialEntry class

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

Parameters
credentialEntry: CredentialEntry

the instance of framework class to be converted

Public constructors

PublicKeyCredentialEntry

Added in 1.5.0-beta01
PublicKeyCredentialEntry(
    context: Context,
    username: CharSequence,
    pendingIntent: PendingIntent,
    beginGetPublicKeyCredentialOption: BeginGetPublicKeyCredentialOption,
    displayName: CharSequence? = null,
    lastUsedTime: Instant? = null,
    icon: Icon = Icon.createWithResource(context, R.drawable.ic_passkey),
    isAutoSelectAllowed: Boolean = false,
    isDefaultIconPreferredAsSingleProvider: Boolean = false
)
Parameters
context: Context

the context of the calling app, required to retrieve fallback resources

username: CharSequence

the username of the account holding the public key credential

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

beginGetPublicKeyCredentialOption: BeginGetPublicKeyCredentialOption

the option from the original BeginGetCredentialRequest, for which this credential entry is being added

displayName: CharSequence? = null

the displayName of the account holding the public key credential

lastUsedTime: Instant? = null

the last used time the credential 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 = Icon.createWithResource(context, R.drawable.ic_passkey)

the icon to be displayed with this entry on the selector, if not set, a default icon representing a public key credential type is set by the library

isAutoSelectAllowed: Boolean = false

whether this entry is allowed to be auto selected if it is the only one on the UI, only takes effect if the app requesting for credentials also opts for auto select

isDefaultIconPreferredAsSingleProvider: Boolean = false

when set to true, the UI prefers to render the default credential type icon (see the default value of icon) when you are the only available provider; false by default

PublicKeyCredentialEntry

Added in 1.5.0-beta01
@RequiresApi
PublicKeyCredentialEntry(
    context: Context,
    username: CharSequence,
    pendingIntent: PendingIntent,
    beginGetPublicKeyCredentialOption: BeginGetPublicKeyCredentialOption,
    displayName: CharSequence? = null,
    lastUsedTime: Instant? = null,
    icon: Icon = Icon.createWithResource(context, R.drawable.ic_passkey),
    isAutoSelectAllowed: Boolean = false,
    isDefaultIconPreferredAsSingleProvider: Boolean = false,
    biometricPromptData: BiometricPromptData? = null
)
Parameters
context: Context

the context of the calling app, required to retrieve fallback resources

username: CharSequence

the username of the account holding the public key credential

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

beginGetPublicKeyCredentialOption: BeginGetPublicKeyCredentialOption

the option from the original BeginGetCredentialRequest, for which this credential entry is being added

displayName: CharSequence? = null

the displayName of the account holding the public key credential

lastUsedTime: Instant? = null

the last used time the credential 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 = Icon.createWithResource(context, R.drawable.ic_passkey)

the icon to be displayed with this entry on the selector, if not set, a default icon representing a public key credential type is set by the library

isAutoSelectAllowed: Boolean = false

whether this entry is allowed to be auto selected if it is the only one on the UI, only takes effect if the app requesting for credentials also opts for auto select

isDefaultIconPreferredAsSingleProvider: Boolean = false

when set to true, the UI prefers to render the default credential type icon (see the default value of icon) when you are the only available provider; false by default

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

Public properties

displayName

Added in 1.2.0
val displayNameCharSequence?

the displayName of the account holding the public key credential

hasDefaultIcon

Added in 1.5.0-beta01
val hasDefaultIconBoolean

whether this entry was created without a custom icon and hence contains a default icon set by the library, only to be used in Android API levels >= 28

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; defaulted to a fallback public key credential icon if not provided

isAutoSelectAllowed

Added in 1.2.0
val isAutoSelectAllowedBoolean

isAutoSelectAllowedFromOption

Added in 1.5.0-beta01
val isAutoSelectAllowedFromOptionBoolean

whether the beginGetCredentialOption request for which this entry was created allows this entry to be auto-selected

lastUsedTime

Added in 1.2.0
val lastUsedTimeInstant?

the last used time of this entry. Note that this value will only be distinguishable up to the milli second mark. 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

typeDisplayName

Added in 1.2.0
val typeDisplayNameCharSequence

username

Added in 1.2.0
val usernameCharSequence

the username of the account holding the public key credential