Added in API level 34

CredentialProviderService


abstract class CredentialProviderService : Service
kotlin.Any
   ↳ android.content.Context
   ↳ android.content.ContextWrapper
   ↳ android.app.Service
   ↳ android.service.credentials.CredentialProviderService

Service to be extended by credential providers, in order to return user credentials to the framework.

Summary

Constants
static String

Intent extra: The BeginGetCredentialRequest attached with the pendingIntent that is invoked when the user selects an authentication entry (intending to unlock the provider app) on the UI.

static String

Intent extra: The result of an authentication flow, to be set on finish of the android.app.Activity invoked through the android.app.PendingIntent set on an authentication Action, as part of the original BeginGetCredentialResponse.

static String

Intent extra: The failure exception set at the final stage of a create flow.

static String

Intent extra: The android.credentials.CreateCredentialRequest attached with the pendingIntent that is invoked when the user selects a CreateEntry returned as part of the BeginCreateCredentialResponse

static String

Intent extra: The result of a create flow operation, to be set on finish of the android.app.Activity invoked through the pendingIntent set on a CreateEntry.

static String

Intent extra: The failure exception set at the final stage of a get flow.

static String

Intent extra: The GetCredentialRequest attached with the pendingIntent that is invoked when the user selects a CredentialEntry returned as part of the BeginGetCredentialResponse

static String

Intent extra: The result of a get credential flow operation, to be set on finish of the android.app.Activity invoked through the pendingIntent set on a CredentialEntry.

static String

The Intent that must be declared as handled by the service.

static String

Name under which a Credential Provider service component publishes information about itself.

Inherited constants
Public constructors

Public methods
abstract Unit

Called by the android system to create a credential.

abstract Unit

Called by the android system to retrieve user credentials from the connected provider service.

IBinder
onBind(intent: Intent)

Return the communication channel to the service.

abstract Unit

Called by the android system to clear the credential state.

open Unit

Called by the system when the service is first created.

Inherited functions

Constants

EXTRA_BEGIN_GET_CREDENTIAL_REQUEST

Added in API level 34
static val EXTRA_BEGIN_GET_CREDENTIAL_REQUEST: String

Intent extra: The BeginGetCredentialRequest attached with the pendingIntent that is invoked when the user selects an authentication entry (intending to unlock the provider app) on the UI.

When a provider app receives a BeginGetCredentialRequest through the CredentialProviderService#onBeginGetCredential call, it can construct the BeginGetCredentialResponse with either an authentication Action (if the app is locked), or a BeginGetCredentialResponse (if the app is unlocked). In the former case, i.e. the app is locked, user will be shown the authentication action. When selected, the underlying PendingIntent will be invoked which will lead the user to provider's unlock activity. This pending intent will also contain the original BeginGetCredentialRequest to be retrieved and processed after the unlock flow is complete.

After the app is unlocked, the BeginGetCredentialResponse must be constructed using a BeginGetCredentialResponse, which must be set on an Intent as an intent extra against CredentialProviderService#EXTRA_CREDENTIALS_RESPONSE_CONTENT}. This intent should then be set as a result through android.app.Activity#setResult before finishing the activity.

Type: BeginGetCredentialRequest

Value: "android.service.credentials.extra.BEGIN_GET_CREDENTIAL_REQUEST"

EXTRA_BEGIN_GET_CREDENTIAL_RESPONSE

Added in API level 34
static val EXTRA_BEGIN_GET_CREDENTIAL_RESPONSE: String

Intent extra: The result of an authentication flow, to be set on finish of the android.app.Activity invoked through the android.app.PendingIntent set on an authentication Action, as part of the original BeginGetCredentialResponse. This result should contain the actual content, including credential entries and action entries, to be shown on the selector.

Type: BeginGetCredentialResponse

Value: "android.service.credentials.extra.BEGIN_GET_CREDENTIAL_RESPONSE"

EXTRA_CREATE_CREDENTIAL_EXCEPTION

Added in API level 34
static val EXTRA_CREATE_CREDENTIAL_EXCEPTION: String

Intent extra: The failure exception set at the final stage of a create flow. This exception is set at the finishing result of the android.app.Activity invoked by the PendingIntent , when a user selects the CreateEntry that contained the PendingIntent in question.

Type: android.credentials.CreateCredentialException

Value: "android.service.credentials.extra.CREATE_CREDENTIAL_EXCEPTION"

EXTRA_CREATE_CREDENTIAL_REQUEST

Added in API level 34
static val EXTRA_CREATE_CREDENTIAL_REQUEST: String

Intent extra: The android.credentials.CreateCredentialRequest attached with the pendingIntent that is invoked when the user selects a CreateEntry returned as part of the BeginCreateCredentialResponse

Type: android.service.credentials.CreateCredentialRequest

Value: "android.service.credentials.extra.CREATE_CREDENTIAL_REQUEST"

EXTRA_CREATE_CREDENTIAL_RESPONSE

Added in API level 34
static val EXTRA_CREATE_CREDENTIAL_RESPONSE: String

Intent extra: The result of a create flow operation, to be set on finish of the android.app.Activity invoked through the pendingIntent set on a CreateEntry.

Type: android.credentials.CreateCredentialResponse

Value: "android.service.credentials.extra.CREATE_CREDENTIAL_RESPONSE"

EXTRA_GET_CREDENTIAL_EXCEPTION

Added in API level 34
static val EXTRA_GET_CREDENTIAL_EXCEPTION: String

Intent extra: The failure exception set at the final stage of a get flow. This exception is set at the finishing result of the android.app.Activity invoked by the PendingIntent , when a user selects the CredentialEntry that contained the PendingIntent in question.

The result must be set through android.app.Activity#setResult as an intent extra

Type: android.credentials.GetCredentialException

Value: "android.service.credentials.extra.GET_CREDENTIAL_EXCEPTION"

EXTRA_GET_CREDENTIAL_REQUEST

Added in API level 34
static val EXTRA_GET_CREDENTIAL_REQUEST: String

Intent extra: The GetCredentialRequest attached with the pendingIntent that is invoked when the user selects a CredentialEntry returned as part of the BeginGetCredentialResponse

Type: GetCredentialRequest

Value: "android.service.credentials.extra.GET_CREDENTIAL_REQUEST"

EXTRA_GET_CREDENTIAL_RESPONSE

Added in API level 34
static val EXTRA_GET_CREDENTIAL_RESPONSE: String

Intent extra: The result of a get credential flow operation, to be set on finish of the android.app.Activity invoked through the pendingIntent set on a CredentialEntry.

Type: android.credentials.GetCredentialResponse

Value: "android.service.credentials.extra.GET_CREDENTIAL_RESPONSE"

SERVICE_INTERFACE

Added in API level 34
static val SERVICE_INTERFACE: String

The Intent that must be declared as handled by the service. The service must also require the {android.Manifest.permission#BIND_CREDENTIAL_PROVIDER_SERVICE} permission so that only the system can bind to it.

Value: "android.service.credentials.CredentialProviderService"

SERVICE_META_DATA

Added in API level 34
static val SERVICE_META_DATA: String

Name under which a Credential Provider service component publishes information about itself. This meta-data must reference an XML resource containing an <credential-provider> tag. For example (AndroidManifest.xml): For example (xml/provider.xml): @string/passwords @string/passkeys

Value: "android.credentials.provider"

Public constructors

CredentialProviderService

CredentialProviderService()

Public methods

onBeginCreateCredential

Added in API level 34
abstract fun onBeginCreateCredential(
    request: BeginCreateCredentialRequest,
    cancellationSignal: CancellationSignal,
    callback: OutcomeReceiver<BeginCreateCredentialResponse!, CreateCredentialException!>
): Unit

Called by the android system to create a credential.

Parameters
request BeginCreateCredentialRequest: The credential creation request for the provider to handle. This value cannot be null.
cancellationSignal CancellationSignal: Signal for providers to listen to any cancellation requests from the android system. This value cannot be null.
callback OutcomeReceiver<BeginCreateCredentialResponse!, CreateCredentialException!>: Object used to relay the response of the credential creation request. This value cannot be null.

onBeginGetCredential

Added in API level 34
abstract fun onBeginGetCredential(
    request: BeginGetCredentialRequest,
    cancellationSignal: CancellationSignal,
    callback: OutcomeReceiver<BeginGetCredentialResponse!, GetCredentialException!>
): Unit

Called by the android system to retrieve user credentials from the connected provider service.

This API denotes a query stage request for getting user's credentials from a given credential provider. The request contains a list of BeginGetCredentialOption that have parameters to be used for populating candidate credentials, as a list of CredentialEntry to be set on the BeginGetCredentialResponse. This list is then shown to the user on a selector.

If a PendingIntent is set on a CredentialEntry, and the user selects that entry, a GetCredentialRequest with all parameters needed to get the actual android.credentials.Credential will be sent as part of the Intent fired through the PendingIntent.

Parameters
request BeginGetCredentialRequest: the request for the provider to handle This value cannot be null.
cancellationSignal CancellationSignal: signal for providers to listen to any cancellation requests from the android system This value cannot be null.
callback OutcomeReceiver<BeginGetCredentialResponse!, GetCredentialException!>: object used to relay the response of the credentials request This value cannot be null.

onBind

Added in API level 34
fun onBind(intent: Intent): IBinder

Return the communication channel to the service. May return null if clients can not bind to the service. The returned android.os.IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: This value cannot be null.
Return
IBinder This value cannot be null.

onClearCredentialState

Added in API level 34
abstract fun onClearCredentialState(
    request: ClearCredentialStateRequest,
    cancellationSignal: CancellationSignal,
    callback: OutcomeReceiver<Void!, ClearCredentialStateException!>
): Unit

Called by the android system to clear the credential state. This api isinvoked by developers after users sign out of an app, with an intention to clear any stored credential session that providers have retained. As a provider, you must clear any credential state, if maintained. For e.g. a provider may have stored an active credential session that is used to limit or rank sign-in options for future credential retrieval flows. When a user signs out of the app, such state should be cleared and an exhaustive list of credentials must be presented to the user on subsequent credential retrieval flows.

Parameters
request ClearCredentialStateRequest: The clear credential request for the provider to handle. This value cannot be null.
cancellationSignal CancellationSignal: Signal for providers to listen to any cancellation requests from the android system. This value cannot be null.
callback OutcomeReceiver<Void!, ClearCredentialStateException!>: Object used to relay the result of the request. This value cannot be null.

onCreate

Added in API level 34
open fun onCreate(): Unit

Called by the system when the service is first created. Do not call this method directly. If you override this method you must call through to the superclass implementation.