CustomCredentialEntry


@RequiresApi(value = 23)
public final class CustomCredentialEntry extends CredentialEntry


Custom credential entry for a custom credential type that is displayed on the account selector UI.

Each entry corresponds to an account that can provide a credential.

Throws
kotlin.IllegalArgumentException

If type or title are empty

See also
CredentialEntry

Summary

Nested types

Builder for CustomCredentialEntry

Public constructors

CustomCredentialEntry(
    @NonNull Context context,
    @NonNull CharSequence title,
    @NonNull PendingIntent pendingIntent,
    @NonNull BeginGetCredentialOption beginGetCredentialOption,
    CharSequence subtitle,
    CharSequence typeDisplayName,
    Instant lastUsedTime,
    @NonNull Icon icon,
    boolean isAutoSelectAllowed,
    @NonNull CharSequence entryGroupId,
    boolean isDefaultIconPreferredAsSingleProvider
)
@RequiresApi
CustomCredentialEntry(
    @NonNull Context context,
    @NonNull CharSequence title,
    @NonNull PendingIntent pendingIntent,
    @NonNull BeginGetCredentialOption beginGetCredentialOption,
    CharSequence subtitle,
    CharSequence typeDisplayName,
    Instant lastUsedTime,
    @NonNull Icon icon,
    boolean isAutoSelectAllowed,
    @NonNull CharSequence entryGroupId,
    boolean isDefaultIconPreferredAsSingleProvider,
    BiometricPromptData biometricPromptData
)

Public methods

static final CustomCredentialEntry

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

final @NonNull 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 custom credential icon if not provided

final Instant

the last used time the credential underlying this entry was used by the user.

final @NonNull PendingIntent

the PendingIntent that will get invoked when the user selects this entry, must be created with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request

final CharSequence

the subTitle shown with this entry on the selector UI

final @NonNull CharSequence

the title shown with this entry on the selector UI

@NonNull String
final CharSequence

the friendly name to be displayed on the UI for the type of the credential

final 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

final boolean

whether this entry is allowed to be auto selected if it is the only one on the UI.

final boolean

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

Inherited methods

From androidx.credentials.provider.CredentialEntry
final 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

final @NonNull BeginGetCredentialOption

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

final 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

final @NonNull CharSequence

an ID used for deduplication or to group entries during display

final 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 constructors

CustomCredentialEntry

Added in 1.5.0-beta01
public CustomCredentialEntry(
    @NonNull Context context,
    @NonNull CharSequence title,
    @NonNull PendingIntent pendingIntent,
    @NonNull BeginGetCredentialOption beginGetCredentialOption,
    CharSequence subtitle,
    CharSequence typeDisplayName,
    Instant lastUsedTime,
    @NonNull Icon icon,
    boolean isAutoSelectAllowed,
    @NonNull CharSequence entryGroupId,
    boolean isDefaultIconPreferredAsSingleProvider
)
Parameters
@NonNull Context context

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

@NonNull CharSequence title

the title shown with this entry on the selector UI

@NonNull PendingIntent pendingIntent

the PendingIntent that will get invoked when the user selects this entry, must be created with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request

@NonNull BeginGetCredentialOption beginGetCredentialOption

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

CharSequence subtitle

the subTitle shown with this entry on the selector UI

CharSequence typeDisplayName

the friendly name to be displayed on the UI for the type of the credential

Instant lastUsedTime

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

@NonNull Icon icon

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

boolean isAutoSelectAllowed

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

@NonNull CharSequence entryGroupId

an ID to uniquely mark this entry for deduplication or to group entries during display, set to title by default

boolean isDefaultIconPreferredAsSingleProvider

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

Throws
kotlin.IllegalArgumentException

If type or title are empty

CustomCredentialEntry

Added in 1.5.0-beta01
@RequiresApi
public CustomCredentialEntry(
    @NonNull Context context,
    @NonNull CharSequence title,
    @NonNull PendingIntent pendingIntent,
    @NonNull BeginGetCredentialOption beginGetCredentialOption,
    CharSequence subtitle,
    CharSequence typeDisplayName,
    Instant lastUsedTime,
    @NonNull Icon icon,
    boolean isAutoSelectAllowed,
    @NonNull CharSequence entryGroupId,
    boolean isDefaultIconPreferredAsSingleProvider,
    BiometricPromptData biometricPromptData
)
Parameters
@NonNull Context context

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

@NonNull CharSequence title

the title shown with this entry on the selector UI

@NonNull PendingIntent pendingIntent

the PendingIntent that will get invoked when the user selects this entry, must be created with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request

@NonNull BeginGetCredentialOption beginGetCredentialOption

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

CharSequence subtitle

the subTitle shown with this entry on the selector UI

CharSequence typeDisplayName

the friendly name to be displayed on the UI for the type of the credential

Instant lastUsedTime

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

@NonNull Icon icon

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

boolean isAutoSelectAllowed

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

@NonNull CharSequence entryGroupId

an ID to uniquely mark this entry for deduplication or to group entries during display, set to title by default

boolean isDefaultIconPreferredAsSingleProvider

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

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 type or title are empty

Public methods

fromCredentialEntry

Added in 1.5.0-beta01
public static final CustomCredentialEntry fromCredentialEntry(@NonNull CredentialEntry credentialEntry)

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

Parameters
@NonNull CredentialEntry credentialEntry

the instance of framework class to be converted

getIcon

Added in 1.2.0
public final @NonNull Icon getIcon()

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 custom credential icon if not provided

getLastUsedTime

Added in 1.2.0
public final Instant getLastUsedTime()

the last used time the credential underlying this entry was used by the user. 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

getPendingIntent

Added in 1.2.0
public final @NonNull PendingIntent getPendingIntent()

the PendingIntent that will get invoked when the user selects this entry, must be created with flag PendingIntent.FLAG_MUTABLE to allow the Android system to attach the final request

getSubtitle

Added in 1.2.0
public final CharSequence getSubtitle()

the subTitle shown with this entry on the selector UI

getTitle

Added in 1.2.0
public final @NonNull CharSequence getTitle()

the title shown with this entry on the selector UI

getType

Added in 1.2.0
public @NonNull String getType()

getTypeDisplayName

Added in 1.2.0
public final CharSequence getTypeDisplayName()

the friendly name to be displayed on the UI for the type of the credential

hasDefaultIcon

Added in 1.5.0-beta01
public final boolean hasDefaultIcon()

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

isAutoSelectAllowed

Added in 1.2.0
public final boolean isAutoSelectAllowed()

whether this entry is allowed to be auto selected if it is the only one on the UI. Note that setting this value to true does not guarantee this behavior. The developer must also set this to true, and the framework must determine that only one entry is present

isAutoSelectAllowedFromOption

Added in 1.5.0-beta01
public final boolean isAutoSelectAllowedFromOption()

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