Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#nestedclasses) \| [Constants](https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#constants) \| [Methods](https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#inhmethods)

# OnDevicePersonalizationManager

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager "View this page in Kotlin") \|Java


`
public


class
OnDevicePersonalizationManager
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.adservices.ondevicepersonalization.OnDevicePersonalizationManager |

<br />

*** ** * ** ***

OnDevicePersonalizationManager provides APIs for apps to load an
`https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` in an isolated process and interact with it.

An app can request an `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` to generate content for display
within an `https://developer.android.com/reference/android/view/SurfaceView` within the app's view hierarchy, and also write
persistent results to on-device storage which can be consumed by Federated Analytics for
cross-device statistical analysis or by Federated Learning for model training. The displayed
content and the persistent output are both not directly accessible by the calling app.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult` The result of a call to `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#execute(android.content.ComponentName,%20android.os.PersistableBundle,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.adservices.ondevicepersonalization.OnDevicePersonalizationManager.ExecuteResult,java.lang.Exception>)` |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#FEATURE_DISABLED` Indicates that a feature is present but disabled on the device. |
| `int` | `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#FEATURE_ENABLED` Indicates that a feature is present and enabled on the device. |
| `int` | `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#FEATURE_UNSUPPORTED` Indicates that a feature is not supported on the device. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#execute(android.content.ComponentName,%20android.os.PersistableBundle,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.adservices.ondevicepersonalization.OnDevicePersonalizationManager.ExecuteResult,java.lang.Exception>)(https://developer.android.com/reference/android/content/ComponentName service, https://developer.android.com/reference/android/os/PersistableBundle params, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/os/OutcomeReceiver<https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult, https://developer.android.com/reference/java/lang/Exception> receiver) ` Executes an `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` in the OnDevicePersonalization sandbox. |
| ` void` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#executeInIsolatedService(android.adservices.ondevicepersonalization.ExecuteInIsolatedServiceRequest,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.adservices.ondevicepersonalization.ExecuteInIsolatedServiceResponse,java.lang.Exception>)(https://developer.android.com/reference/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceRequest request, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/os/OutcomeReceiver<https://developer.android.com/reference/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceResponse, https://developer.android.com/reference/java/lang/Exception> receiver) ` Executes an `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` in the OnDevicePersonalization sandbox. |
| ` void` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#queryFeatureAvailability(java.lang.String,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<java.lang.Integer,java.lang.Exception>)(https://developer.android.com/reference/java/lang/String featureName, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/os/OutcomeReceiver<https://developer.android.com/reference/java/lang/Integer, https://developer.android.com/reference/java/lang/Exception> receiver) ` Get the status of a specific OnDevicePersonalization feature. |
| ` void` | ` https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken,%20android.os.IBinder,%20int,%20int,%20int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.view.SurfaceControlViewHost.SurfacePackage,java.lang.Exception>)(https://developer.android.com/reference/android/adservices/ondevicepersonalization/SurfacePackageToken surfacePackageToken, https://developer.android.com/reference/android/os/IBinder surfaceViewHostToken, int displayId, int width, int height, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/os/OutcomeReceiver<https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage, https://developer.android.com/reference/java/lang/Exception> receiver) ` Requests a `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` to be inserted into a `https://developer.android.com/reference/android/view/SurfaceView` inside the calling app. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### FEATURE_DISABLED

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int FEATURE_DISABLED
```

Indicates that a feature is present but disabled on the device.

<br />

Constant Value:

1
(0x00000001)


### FEATURE_ENABLED

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int FEATURE_ENABLED
```

Indicates that a feature is present and enabled on the device.

<br />

Constant Value:

0
(0x00000000)


### FEATURE_UNSUPPORTED

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public static final int FEATURE_UNSUPPORTED
```

Indicates that a feature is not supported on the device.

<br />

Constant Value:

2
(0x00000002)


## Public methods

### execute

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void execute (ComponentName service, 
                PersistableBundle params, 
                Executor executor, 
                OutcomeReceiver<OnDevicePersonalizationManager.ExecuteResult, Exception> receiver)
```

Executes an `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` in the OnDevicePersonalization sandbox. The platform
binds to the specified `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` in an isolated process and calls `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedWorker#onExecute(android.adservices.ondevicepersonalization.ExecuteInput,%20android.os.OutcomeReceiver<android.adservices.ondevicepersonalization.ExecuteOutput,android.adservices.ondevicepersonalization.IsolatedServiceException>)` with the caller-provided
parameters. When the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` finishes execution, the platform returns tokens
that refer to the results from the service to the caller. These tokens can be subsequently
used to display results in a `https://developer.android.com/reference/android/view/SurfaceView` within the calling app.

<br />

| Parameters ||
|---|---|
| `service` | `ComponentName`: The `https://developer.android.com/reference/android/content/ComponentName` of the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService`. This value cannot be `null`. <br /> |
| `params` | `PersistableBundle`: a `https://developer.android.com/reference/android/os/PersistableBundle` that is passed from the calling app to the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService`. The expected contents of this parameter are defined by the`https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService`. The platform does not interpret this parameter. This value cannot be `null`. <br /> |
| `executor` | `Executor`: the `https://developer.android.com/reference/java/util/concurrent/Executor` on which to invoke the callback. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `receiver` | `OutcomeReceiver`: This returns a `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult` object on success or an `https://developer.android.com/reference/java/lang/Exception` on failure. If the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` returned a `https://developer.android.com/reference/android/adservices/ondevicepersonalization/RenderingConfig` to be displayed, `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult#getSurfacePackageToken()` will return a non-null `https://developer.android.com/reference/android/adservices/ondevicepersonalization/SurfacePackageToken`. The `https://developer.android.com/reference/android/adservices/ondevicepersonalization/SurfacePackageToken` object can be used in a subsequent `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager#requestSurfacePackage(android.adservices.ondevicepersonalization.SurfacePackageToken,%20android.os.IBinder,%20int,%20int,%20int,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.view.SurfaceControlViewHost.SurfacePackage,java.lang.Exception>)` call to display the result in a view. The returned `https://developer.android.com/reference/android/adservices/ondevicepersonalization/SurfacePackageToken` may be null to indicate that no output is expected to be displayed for this request. If the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` has returned any output data and the calling app is allowlisted to receive data from this service, the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationManager.ExecuteResult#getOutputData()` will return a non-null byte array. In case of an error, the receiver returns one of the following exceptions: Returns a `https://developer.android.com/reference/android/content/pm/PackageManager.NameNotFoundException` if the handler package is not installed or does not have a valid ODP manifest. Returns `https://developer.android.com/reference/java/lang/ClassNotFoundException` if the handler class is not found. Returns an `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationException` if execution of the handler fails. |

### executeInIsolatedService

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void executeInIsolatedService (ExecuteInIsolatedServiceRequest request, 
                Executor executor, 
                OutcomeReceiver<ExecuteInIsolatedServiceResponse, Exception> receiver)
```

Executes an `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` in the OnDevicePersonalization sandbox. The platform
binds to the specified `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` in an isolated process and calls `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedWorker#onExecute(android.adservices.ondevicepersonalization.ExecuteInput,%20android.os.OutcomeReceiver<android.adservices.ondevicepersonalization.ExecuteOutput,android.adservices.ondevicepersonalization.IsolatedServiceException>)` with the caller-provided
parameters. When the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/IsolatedService` finishes execution, the platform returns tokens
that refer to the results from the service to the caller. These tokens can be subsequently
used to display results in a `https://developer.android.com/reference/android/view/SurfaceView` within the calling app.

<br />

| Parameters ||
|---|---|
| `request` | `ExecuteInIsolatedServiceRequest`: the `https://developer.android.com/reference/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceRequest` request. This value cannot be `null`. <br /> |
| `executor` | `Executor`: the `https://developer.android.com/reference/java/util/concurrent/Executor` on which to invoke the callback. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `receiver` | `OutcomeReceiver`: This returns a `https://developer.android.com/reference/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceResponse` object on success or an `https://developer.android.com/reference/java/lang/Exception` on failure. For success case, refer to `https://developer.android.com/reference/android/adservices/ondevicepersonalization/ExecuteInIsolatedServiceResponse`. For error case, the receiver returns an `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationException` if execution of the handler fails. This value cannot be `null`. <br /> |

### queryFeatureAvailability

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public void queryFeatureAvailability (String featureName, 
                Executor executor, 
                OutcomeReceiver<Integer, Exception> receiver)
```

Get the status of a specific OnDevicePersonalization feature.

<br />

| Parameters ||
|---|---|
| `featureName` | `String`: the name of the specific feature to check the availability of. This value cannot be `null`. <br /> |
| `executor` | `Executor`: the `https://developer.android.com/reference/java/util/concurrent/Executor` on which to invoke the callback. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `receiver` | `OutcomeReceiver`: this either returns a value of `FeatureStatus` on success or `https://developer.android.com/reference/java/lang/Exception` on failure. The exception type is `https://developer.android.com/reference/java/lang/IllegalStateException` if the service is not available. This value cannot be `null`. <br /> |

### requestSurfacePackage

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void requestSurfacePackage (SurfacePackageToken surfacePackageToken, 
                IBinder surfaceViewHostToken, 
                int displayId, 
                int width, 
                int height, 
                Executor executor, 
                OutcomeReceiver<SurfaceControlViewHost.SurfacePackage, Exception> receiver)
```

Requests a `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` to be inserted into a
`https://developer.android.com/reference/android/view/SurfaceView` inside the calling app. The surface package will contain an
`https://developer.android.com/reference/android/view/View` with the content from a result of a prior call to
`#execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver)` running in
the OnDevicePersonalization sandbox.

<br />

| Parameters ||
|---|---|
| `surfacePackageToken` | `SurfacePackageToken`: a reference to a `https://developer.android.com/reference/android/adservices/ondevicepersonalization/SurfacePackageToken` returned by a prior call to `#execute(ComponentName, PersistableBundle, Executor, OutcomeReceiver)`. This value cannot be `null`. <br /> |
| `surfaceViewHostToken` | `IBinder`: the hostToken of the `https://developer.android.com/reference/android/view/SurfaceView`, which is returned by `https://developer.android.com/reference/android/view/SurfaceView#getHostToken()` after the `https://developer.android.com/reference/android/view/SurfaceView` has been added to the view hierarchy. This value cannot be `null`. <br /> |
| `displayId` | `int`: the integer ID of the logical display on which to display the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage`, returned by `Context.getDisplay().getDisplayId()`. <br /> |
| `width` | `int`: the width of the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` in pixels. <br /> |
| `height` | `int`: the height of the `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` in pixels. <br /> |
| `executor` | `Executor`: the `https://developer.android.com/reference/java/util/concurrent/Executor` on which to invoke the callback. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `receiver` | `OutcomeReceiver`: This either returns a `https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage` on success, or `https://developer.android.com/reference/java/lang/Exception` on failure. The exception type is `https://developer.android.com/reference/android/adservices/ondevicepersonalization/OnDevicePersonalizationException` if execution of the handler fails. This value cannot be `null`. <br /> |