interface AgeSignalProvider


Provider interface to be implemented by age signal providers that will fulfill AgeSignalManager requests.

Implementations must provide a public constructor that accepts a single Context parameter.

Providers are discovered via metadata declared inside a <service> in AndroidManifest.xml:

<service
android:name=".MyAgeSignalProviderService"
android:exported="false">
<meta-data
android:name="androidx.credentials.agesignals.AGE_SIGNAL_PROVIDER_KEY"
android:value="com.example.provider.MyAgeSignalProvider" />
</service>

Summary

Public functions

Boolean

Determines whether the provider is supported and available on the current device.

Unit
onGetAgeRange(
    context: Context,
    request: GetAgeRangeRequest,
    cancellationSignal: CancellationSignal?,
    executor: Executor,
    callback: OutcomeReceiverCompat<GetAgeRangeResponse, GetAgeRangeException>
)

Invoked when an application requests age range information.

Public functions

isAvailable

Added in 1.0.0-alpha01
fun isAvailable(): Boolean

Determines whether the provider is supported and available on the current device.

Returns
Boolean

true if this provider can fulfill requests on this device; false otherwise

onGetAgeRange

Added in 1.0.0-alpha01
fun onGetAgeRange(
    context: Context,
    request: GetAgeRangeRequest,
    cancellationSignal: CancellationSignal?,
    executor: Executor,
    callback: OutcomeReceiverCompat<GetAgeRangeResponse, GetAgeRangeException>
): Unit

Invoked when an application requests age range information.

Parameters
context: Context

the client calling context used to launch any interactive UI (e.g. user consent or parental verification dialogs)

request: GetAgeRangeRequest

the request for getting the user's age range

cancellationSignal: CancellationSignal?

an optional signal allowing the caller to cancel the in-flight operation

executor: Executor

the executor on which the callback must be invoked

callback: OutcomeReceiverCompat<GetAgeRangeResponse, GetAgeRangeException>

the callback invoked upon successful retrieval or failure