PublicKeyCredentialEntry
@RequiresApi(value = 23)
public final class PublicKeyCredentialEntry extends CredentialEntry
| java.lang.Object | ||
| ↳ | androidx.credentials.provider.CredentialEntry | |
| ↳ | androidx.credentials.provider.PublicKeyCredentialEntry |
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.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If |
| See also | |
|---|---|
CredentialEntry |
Summary
Nested types |
|---|
public final class PublicKeyCredentialEntry.BuilderBuilder for |
Public constructors |
|---|
PublicKeyCredentialEntry( |
@RequiresApi(value = 35) |
Public methods |
|
|---|---|
static final PublicKeyCredentialEntry |
fromCredentialEntry(@NonNull CredentialEntry credentialEntry)Converts a framework |
final CharSequence |
the displayName of the account holding the public key credential |
final @NonNull Icon |
getIcon()the icon to be displayed with this entry on the UI, must be created using |
final Instant |
the last used time of this entry. |
final @NonNull PendingIntent |
the |
final @NonNull CharSequence |
|
final @NonNull CharSequence |
the username of the account holding the public key 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 |
|
final boolean |
whether the |
Inherited methods |
||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
PublicKeyCredentialEntry
public PublicKeyCredentialEntry(
@NonNull Context context,
@NonNull CharSequence username,
@NonNull PendingIntent pendingIntent,
@NonNull BeginGetPublicKeyCredentialOption beginGetPublicKeyCredentialOption,
CharSequence displayName,
Instant lastUsedTime,
@NonNull Icon icon,
boolean isAutoSelectAllowed,
boolean isDefaultIconPreferredAsSingleProvider
)
| Parameters | |
|---|---|
@NonNull Context context |
the context of the calling app, required to retrieve fallback resources |
@NonNull CharSequence username |
the username of the account holding the public key credential |
@NonNull PendingIntent pendingIntent |
the |
@NonNull BeginGetPublicKeyCredentialOption beginGetPublicKeyCredentialOption |
the option from the original |
CharSequence displayName |
the displayName of the account holding the public key 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, if not set, a default icon representing a public key 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 |
boolean isDefaultIconPreferredAsSingleProvider |
when set to true, the UI prefers to render the default credential type icon (see the default value of |
| Throws | |
|---|---|
kotlin.NullPointerException |
If |
kotlin.IllegalArgumentException |
if |
PublicKeyCredentialEntry
@RequiresApi(value = 35)
public PublicKeyCredentialEntry(
@NonNull Context context,
@NonNull CharSequence username,
@NonNull PendingIntent pendingIntent,
@NonNull BeginGetPublicKeyCredentialOption beginGetPublicKeyCredentialOption,
CharSequence displayName,
Instant lastUsedTime,
@NonNull Icon icon,
boolean isAutoSelectAllowed,
boolean isDefaultIconPreferredAsSingleProvider,
BiometricPromptData biometricPromptData
)
| Parameters | |
|---|---|
@NonNull Context context |
the context of the calling app, required to retrieve fallback resources |
@NonNull CharSequence username |
the username of the account holding the public key credential |
@NonNull PendingIntent pendingIntent |
the |
@NonNull BeginGetPublicKeyCredentialOption beginGetPublicKeyCredentialOption |
the option from the original |
CharSequence displayName |
the displayName of the account holding the public key 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, if not set, a default icon representing a public key 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 |
boolean isDefaultIconPreferredAsSingleProvider |
when set to true, the UI prefers to render the default credential type icon (see the default value of |
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.NullPointerException |
If |
kotlin.IllegalArgumentException |
if |
Public methods
fromCredentialEntry
public static final PublicKeyCredentialEntry fromCredentialEntry(@NonNull CredentialEntry credentialEntry)
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 | |
|---|---|
@NonNull CredentialEntry credentialEntry |
the instance of framework class to be converted |
getDisplayName
public final CharSequence getDisplayName()
the displayName of the account holding the public key credential
getIcon
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 public key credential icon if not provided
getLastUsedTime
public final Instant getLastUsedTime()
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
getPendingIntent
public final @NonNull PendingIntent getPendingIntent()
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
getUsername
public final @NonNull CharSequence getUsername()
the username of the account holding the public key credential
hasDefaultIcon
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
isAutoSelectAllowedFromOption
public final boolean isAutoSelectAllowedFromOption()
whether the beginGetCredentialOption request for which this entry was created allows this entry to be auto-selected