# MeasurementManager

Artifact: [androidx.privacysandbox.ads:ads-adservices](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads) [View Source](https://cs.android.com/search?q=file:androidx/privacysandbox/ads/adservices/measurement/MeasurementManager.kt+class:androidx.privacysandbox.ads.adservices.measurement.MeasurementManager) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

*** ** * ** ***


```
public abstract class MeasurementManager
```

<br />

*** ** * ** ***

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

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#MEASUREMENT_API_STATE_DISABLED() = 0` This state indicates that Measurement APIs are unavailable. |
| `static final int` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#MEASUREMENT_API_STATE_ENABLED() = 1` This state indicates that Measurement APIs are enabled. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#MeasurementManager()()` |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#deleteRegistrations(androidx.privacysandbox.ads.adservices.measurement.DeletionRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/DeletionRequest deletionRequest)` Delete previous registrations. |
| `abstract int` | `@https://developer.android.com/reference/androidx/annotation/RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION") https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#getMeasurementApiStatus()()` Get Measurement API status. |
| `static final https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager` | `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#obtain(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context)` Creates `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager`. |
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION") @https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/common/ExperimentalFeatures.RegisterSourceOptIn https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#registerSource(androidx.privacysandbox.ads.adservices.measurement.SourceRegistrationRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/SourceRegistrationRequest request)` Register an attribution source(click or view) context. |
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION") https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#registerSource(android.net.Uri,android.view.InputEvent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html attributionSource, https://developer.android.com/reference/android/view/InputEvent.html inputEvent)` Register an attribution source (click or view). |
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION") https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#registerTrigger(android.net.Uri)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html trigger)` Register a trigger (conversion). |
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION") https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#registerWebSource(androidx.privacysandbox.ads.adservices.measurement.WebSourceRegistrationRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/WebSourceRegistrationRequest request)` Register an attribution source(click or view) from web context. |
| `abstract void` | `@https://developer.android.com/reference/androidx/annotation/RequiresPermission(value = "android.permission.ACCESS_ADSERVICES_ATTRIBUTION") https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#registerWebTrigger(androidx.privacysandbox.ads.adservices.measurement.WebTriggerRegistrationRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/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 `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html`.

### 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](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public MeasurementManager()
```

## Public methods

### deleteRegistrations

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public abstract void deleteRegistrations(@NonNull DeletionRequest deletionRequest)
```

Delete previous registrations.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/DeletionRequest deletionRequest` | The request for deleting data. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the caller is not authorized to call the API. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the API is disabled, the caller app is in background or user consent hasn't been granted yet. |
| `https://developer.android.com/reference/android/os/LimitExceededException.html` | 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 `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#MEASUREMENT_API_STATE_DISABLED()` and `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager#MEASUREMENT_API_STATE_ENABLED()` for possible values). |

### obtain

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

```
public static final MeasurementManager obtain(@NonNull Context context)
```

Creates `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager`.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/MeasurementManager` | MeasurementManager object. If the device is running an incompatible build, the value returned is null. |

### registerSource

Added in [1.1.0-beta12](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.1.0-beta12)

```
@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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/SourceRegistrationRequest request` | source registration request |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the caller is not authorized to call the API. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the API is disabled, the caller app is in background or user consent hasn't been granted yet. |
| `https://developer.android.com/reference/android/os/LimitExceededException.html` | if the API invocation rate limit is exceeded. |

### registerSource

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html attributionSource` | the platform issues a request to this URI in order to fetch metadata associated with the attribution source. |
| `https://developer.android.com/reference/android/view/InputEvent.html inputEvent` | either an `https://developer.android.com/reference/android/view/InputEvent.html` object (for a click event) or null (for a view event). |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the caller is not authorized to call the API. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the API is disabled or the caller app is in background. |
| `https://developer.android.com/reference/android/os/LimitExceededException.html` | if the API invocation rate limit is exceeded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the API is invoked with invalid arguments. |

### registerTrigger

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#1.0.0)

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

Register a trigger (conversion).

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/net/Uri.html trigger` | the API issues a request to this URI to fetch metadata associated with the trigger. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the caller is not authorized to call the API. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the API is disabled, the caller app is in background or user consent hasn't been granted yet. |
| `https://developer.android.com/reference/android/os/LimitExceededException.html` | if the API invocation rate limit is exceeded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the API is invoked with invalid arguments. |

### registerWebSource

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/WebSourceRegistrationRequest request` | source registration request |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the caller is not authorized to call the API. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the API is disabled, the caller app is in background or user consent hasn't been granted yet. |
| `https://developer.android.com/reference/android/os/LimitExceededException.html` | if the API invocation rate limit is exceeded. |

### registerWebTrigger

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/privacysandbox-ads#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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/privacysandbox/ads/adservices/measurement/WebTriggerRegistrationRequest request` | trigger registration request |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException.html` | if the caller is not authorized to call the API. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if the API is disabled, the caller app is in background or user consent hasn't been granted yet. |
| `https://developer.android.com/reference/android/os/LimitExceededException.html` | if the API invocation rate limit is exceeded. |