public 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 methods

abstract boolean

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

abstract void
onGetAgeRange(
    @NonNull Context context,
    @NonNull GetAgeRangeRequest request,
    CancellationSignal cancellationSignal,
    @NonNull Executor executor,
    @NonNull OutcomeReceiverCompat<@NonNull GetAgeRangeResponse, @NonNull GetAgeRangeException> callback
)

Invoked when an application requests age range information.

Public methods

isAvailable

Added in 1.0.0-alpha01
abstract boolean isAvailable()

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
abstract void onGetAgeRange(
    @NonNull Context context,
    @NonNull GetAgeRangeRequest request,
    CancellationSignal cancellationSignal,
    @NonNull Executor executor,
    @NonNull OutcomeReceiverCompat<@NonNull GetAgeRangeResponse, @NonNull GetAgeRangeException> callback
)

Invoked when an application requests age range information.

Parameters
@NonNull Context context

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

@NonNull GetAgeRangeRequest request

the request for getting the user's age range

CancellationSignal cancellationSignal

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

@NonNull Executor executor

the executor on which the callback must be invoked

@NonNull OutcomeReceiverCompat<@NonNull GetAgeRangeResponse, @NonNull GetAgeRangeException> callback

the callback invoked upon successful retrieval or failure