CustomCredentialEntry


@RequiresApi(value = 26)
class CustomCredentialEntry : 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 companion functions

CustomCredentialEntry?

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

Public constructors

CustomCredentialEntry(
    context: Context,
    title: CharSequence,
    pendingIntent: PendingIntent,
    beginGetCredentialOption: BeginGetCredentialOption,
    subtitle: CharSequence?,
    typeDisplayName: CharSequence?,
    lastUsedTime: Instant?,
    icon: Icon,
    isAutoSelectAllowed: Boolean,
    entryGroupId: CharSequence,
    isDefaultIconPreferredAsSingleProvider: Boolean
)

Public properties

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

Boolean

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

Boolean

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

Instant?

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

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

CharSequence?

the subTitle shown with this entry on the selector UI

CharSequence

the title shown with this entry on the selector UI

open String
CharSequence?

the friendly name to be displayed on the UI for the type of the 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

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.3.0-alpha03
fun fromCredentialEntry(credentialEntry: CredentialEntry): CustomCredentialEntry?

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

Parameters
credentialEntry: CredentialEntry

the instance of framework class to be converted

Public constructors

CustomCredentialEntry

Added in 1.3.0-alpha03
CustomCredentialEntry(
    context: Context,
    title: CharSequence,
    pendingIntent: PendingIntent,
    beginGetCredentialOption: BeginGetCredentialOption,
    subtitle: CharSequence? = null,
    typeDisplayName: CharSequence? = null,
    lastUsedTime: Instant? = null,
    icon: Icon = Icon.createWithResource(context, R.drawable.ic_other_sign_in),
    isAutoSelectAllowed: Boolean = false,
    entryGroupId: CharSequence = title,
    isDefaultIconPreferredAsSingleProvider: Boolean = false
)
Parameters
context: Context

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

title: CharSequence

the title shown with this entry on the selector UI

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

beginGetCredentialOption: BeginGetCredentialOption

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

subtitle: CharSequence? = null

the subTitle shown with this entry on the selector UI

typeDisplayName: CharSequence? = null

the friendly name to be displayed on the UI for the type of the 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_other_sign_in)

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

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

entryGroupId: CharSequence = title

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

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

Throws
kotlin.IllegalArgumentException

If type or title are empty

Public properties

hasDefaultIcon

Added in 1.3.0-alpha03
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 custom credential icon if not provided

isAutoSelectAllowed

Added in 1.2.0
val isAutoSelectAllowedBoolean

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.3.0-alpha03
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 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

pendingIntent

Added in 1.2.0
val pendingIntentPendingIntent

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

subtitle

Added in 1.2.0
val subtitleCharSequence?

the subTitle shown with this entry on the selector UI

title

Added in 1.2.0
val titleCharSequence

the title shown with this entry on the selector UI

type

Added in 1.2.0
open val typeString

typeDisplayName

Added in 1.2.0
val typeDisplayNameCharSequence?

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