MeasurementManager


abstract class MeasurementManager


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

Summary

Constants

const Int

This state indicates that Measurement APIs are unavailable.

const Int

This state indicates that Measurement APIs are enabled.

Public companion functions

MeasurementManager?
obtain(context: Context)

Creates MeasurementManager.

Public constructors

Public functions

abstract suspend Unit

Delete previous registrations.

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

Get Measurement API status.

abstract suspend Unit
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
@ExperimentalFeatures.RegisterSourceOptIn
registerSource(request: SourceRegistrationRequest)

Register an attribution source(click or view) context.

abstract suspend Unit
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerSource(attributionSource: Uri, inputEvent: InputEvent?)

Register an attribution source (click or view).

abstract suspend Unit
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerTrigger(trigger: Uri)

Register a trigger (conversion).

abstract suspend Unit
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerWebSource(request: WebSourceRegistrationRequest)

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

abstract suspend Unit
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
registerWebTrigger(request: WebTriggerRegistrationRequest)

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

Constants

MEASUREMENT_API_STATE_DISABLED

const val MEASUREMENT_API_STATE_DISABLED = 0: Int

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

MEASUREMENT_API_STATE_ENABLED

const val MEASUREMENT_API_STATE_ENABLED = 1: Int

This state indicates that Measurement APIs are enabled.

Public companion functions

obtain

Added in 1.0.0
fun obtain(context: Context): MeasurementManager?

Creates MeasurementManager.

Returns
MeasurementManager?

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

Public constructors

MeasurementManager

Added in 1.0.0
MeasurementManager()

Public functions

deleteRegistrations

Added in 1.0.0
abstract suspend fun deleteRegistrations(deletionRequest: DeletionRequest): Unit

Delete previous registrations.

Parameters
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")
abstract suspend fun getMeasurementApiStatus(): Int

Get Measurement API status.

Returns
Int

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

registerSource

Added in 1.1.0-beta11
@RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION")
@ExperimentalFeatures.RegisterSourceOptIn
abstract suspend fun registerSource(request: SourceRegistrationRequest): Unit

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
request: SourceRegistrationRequest

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")
abstract suspend fun registerSource(attributionSource: Uri, inputEvent: InputEvent?): Unit

Register an attribution source (click or view).

Parameters
attributionSource: Uri

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")
abstract suspend fun registerTrigger(trigger: Uri): Unit

Register a trigger (conversion).

Parameters
trigger: Uri

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")
abstract suspend fun registerWebSource(request: WebSourceRegistrationRequest): Unit

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
request: WebSourceRegistrationRequest

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")
abstract suspend fun registerWebTrigger(request: WebTriggerRegistrationRequest): Unit

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
request: WebTriggerRegistrationRequest

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.