MeasurementManager


public abstract class MeasurementManager


This class provides APIs to manage ads attribution using Privacy Sandbox.

Summary

Constants

static final int

This state indicates that Measurement APIs are unavailable.

static final int

This state indicates that Measurement APIs are enabled.

Public constructors

Public methods

abstract void

Delete previous registrations.

abstract int
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
getMeasurementApiStatus()

Get Measurement API status.

static final MeasurementManager

Creates MeasurementManager.

abstract void
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
@ExperimentalFeatures.RegisterSourceOptIn
registerSource(@NonNull SourceRegistrationRequest request)

Register an attribution source(click or view) context.

abstract void
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerSource(@NonNull Uri attributionSource, InputEvent inputEvent)

Register an attribution source (click or view).

abstract void
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerTrigger(@NonNull Uri trigger)

Register a trigger (conversion).

abstract void
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerWebSource(@NonNull WebSourceRegistrationRequest request)

Register an attribution source(click or view) from web context.

abstract void
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerWebTrigger(@NonNull WebTriggerRegistrationRequest request)

Register an attribution trigger(click or view) from web context.

Constants

MEASUREMENT_API_STATE_DISABLED

public static final int MEASUREMENT_API_STATE_DISABLED = 0

This state indicates that Measurement APIs are unavailable. Invoking them will result in an UnsupportedOperationException.

MEASUREMENT_API_STATE_ENABLED

public static final int MEASUREMENT_API_STATE_ENABLED = 1

This state indicates that Measurement APIs are enabled.

Public constructors

MeasurementManager

Added in 1.0.0
public MeasurementManager()

Public methods

deleteRegistrations

Added in 1.0.0
public abstract void deleteRegistrations(@NonNull DeletionRequest deletionRequest)

Delete previous registrations.

Parameters
@NonNull DeletionRequest deletionRequest

The request for deleting data.

Throws
java.lang.SecurityException

if the caller is not authorized to call the API.

kotlin.IllegalStateException

if the API is disabled, the caller app is in background or user consent hasn't been granted yet.

android.os.LimitExceededException

if the API invocation rate limit is exceeded.

getMeasurementApiStatus

@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
public abstract int getMeasurementApiStatus()

Get Measurement API status.

Returns
int

an integer value (see MEASUREMENT_API_STATE_DISABLED and MEASUREMENT_API_STATE_ENABLED for possible values).

obtain

Added in 1.0.0
public static final MeasurementManager obtain(@NonNull Context context)

Creates MeasurementManager.

Returns
MeasurementManager

MeasurementManager object. If the device is running an incompatible build, the value returned is null.

registerSource

Added in 1.1.0-beta11
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
@ExperimentalFeatures.RegisterSourceOptIn
public abstract void registerSource(@NonNull SourceRegistrationRequest request)

Register an attribution source(click or view) context. This API will not process any redirects, all registration URLs should be supplied with the request.

Parameters
@NonNull SourceRegistrationRequest request

source registration request

Throws
java.lang.SecurityException

if the caller is not authorized to call the API.

kotlin.IllegalStateException

if the API is disabled, the caller app is in background or user consent hasn't been granted yet.

android.os.LimitExceededException

if the API invocation rate limit is exceeded.

registerSource

Added in 1.0.0
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
public abstract void registerSource(@NonNull Uri attributionSource, InputEvent inputEvent)

Register an attribution source (click or view).

Parameters
@NonNull Uri attributionSource

the platform issues a request to this URI in order to fetch metadata associated with the attribution source.

InputEvent inputEvent

either an InputEvent object (for a click event) or null (for a view event).

Throws
java.lang.SecurityException

if the caller is not authorized to call the API.

kotlin.IllegalStateException

if the API is disabled or the caller app is in background.

android.os.LimitExceededException

if the API invocation rate limit is exceeded.

kotlin.IllegalArgumentException

if the API is invoked with invalid arguments.

registerTrigger

Added in 1.0.0
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
public abstract void registerTrigger(@NonNull Uri trigger)

Register a trigger (conversion).

Parameters
@NonNull Uri trigger

the API issues a request to this URI to fetch metadata associated with the trigger.

Throws
java.lang.SecurityException

if the caller is not authorized to call the API.

kotlin.IllegalStateException

if the API is disabled, the caller app is in background or user consent hasn't been granted yet.

android.os.LimitExceededException

if the API invocation rate limit is exceeded.

kotlin.IllegalArgumentException

if the API is invoked with invalid arguments.

registerWebSource

Added in 1.0.0
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
public abstract void registerWebSource(@NonNull WebSourceRegistrationRequest request)

Register an attribution source(click or view) from web context. This API will not process any redirects, all registration URLs should be supplied with the request. At least one of appDestination or webDestination parameters are required to be provided.

Parameters
@NonNull WebSourceRegistrationRequest request

source registration request

Throws
java.lang.SecurityException

if the caller is not authorized to call the API.

kotlin.IllegalStateException

if the API is disabled, the caller app is in background or user consent hasn't been granted yet.

android.os.LimitExceededException

if the API invocation rate limit is exceeded.

registerWebTrigger

Added in 1.0.0
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
public abstract void registerWebTrigger(@NonNull WebTriggerRegistrationRequest request)

Register an attribution trigger(click or view) from web context. This API will not process any redirects, all registration URLs should be supplied with the request.

Parameters
@NonNull WebTriggerRegistrationRequest request

trigger registration request

Throws
java.lang.SecurityException

if the caller is not authorized to call the API.

kotlin.IllegalStateException

if the API is disabled, the caller app is in background or user consent hasn't been granted yet.

android.os.LimitExceededException

if the API invocation rate limit is exceeded.