public interface AgeSignalManager


Query the age signal of the current device user.

Obtain an instance via AgeSignalManager.create.

Summary

Public methods

default static final @NonNull AgeSignalManager

Creates an AgeSignalManager instance associated with the given context.

default @NonNull GetAgeRangeResponse

Requests the user's age range.

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

Requests the user's age range.

Public methods

create

Added in 1.0.0-alpha01
default static final @NonNull AgeSignalManager create(@NonNull Context context)

Creates an AgeSignalManager instance associated with the given context.

Parameters
@NonNull Context context

the context to associate with this manager

getAgeRange

default @NonNull GetAgeRangeResponse getAgeRange(@NonNull Context context, @NonNull GetAgeRangeRequest request)

Requests the user's age range.

The execution can potentially launch UI flows to collect user consent to sharing their age range.

Parameters
@NonNull Context context

the android.app.Activity context used to launch any UI needed

@NonNull GetAgeRangeRequest request

the request for getting the user's age range

Throws
GetAgeRangeException

if the request fails

getAgeRangeAsync

Added in 1.0.0-alpha01
abstract void getAgeRangeAsync(
    @NonNull Context context,
    @NonNull GetAgeRangeRequest request,
    CancellationSignal cancellationSignal,
    @NonNull Executor executor,
    @NonNull OutcomeReceiverCompat<@NonNull GetAgeRangeResponse, @NonNull GetAgeRangeException> callback
)

Requests the user's age range.

This API uses callbacks instead of Kotlin coroutines.

The execution can potentially launch UI flows to collect user consent to sharing their age range.

Parameters
@NonNull Context context

the android.app.Activity context used to launch any UI needed

@NonNull GetAgeRangeRequest request

the request for getting the user's age range

CancellationSignal cancellationSignal

an optional signal that allows for cancelling this call

@NonNull Executor executor

the callback will take place on this executor

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

the callback invoked when the request succeeds or fails