Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in[Ad Services Extensions 5](https://developer.android.com/sdkExtensions)  
Summary:[Constants](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#constants)\|[Methods](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#pubmethods)\|[Inherited Methods](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#inhmethods)  

# SdkSandboxController

`
public


class
SdkSandboxController
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|---------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.sdksandbox.sdkprovider.SdkSandboxController |

<br />

*** ** * ** ***

Controller that is used by SDK loaded in the sandbox to access information provided by the sdk sandbox.

It enables the SDK to communicate with other SDKS in the SDK sandbox and know about the state of the sdks that are currently loaded in it.

An instance of[SdkSandboxController](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController)can be obtained using[Context.getSystemService(Class)](https://developer.android.com/reference/android/content/Context#getSystemService(java.lang.Class<T>))and[class](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController). The[Context](https://developer.android.com/reference/android/content/Context)can in turn be obtained using[SandboxedSdkProvider.getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext()).

## Summary

|                                                                                                                           ### Constants                                                                                                                           ||
|--------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | [SDK_SANDBOX_CONTROLLER_SERVICE](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#SDK_SANDBOX_CONTROLLER_SERVICE) <br /> |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[AppOwnedSdkSandboxInterface](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/AppOwnedSdkSandboxInterface)`>` | ` `[getAppOwnedSdkSandboxInterfaces](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#getAppOwnedSdkSandboxInterfaces())`() ` Fetches all[AppOwnedSdkSandboxInterface](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/AppOwnedSdkSandboxInterface)that are registered by the app.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                  | ` `[getClientPackageName](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#getClientPackageName())`() ` Returns the package name of the client app.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences)                                                                                                                      | ` `[getClientSharedPreferences](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#getClientSharedPreferences())`() ` Returns[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences)containing data synced from the client app.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ` `[List](https://developer.android.com/reference/java/util/List)`<`[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk)`>`                               | ` `[getSandboxedSdks](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#getSandboxedSdks())`() ` Fetches information about Sdks that are loaded in the sandbox.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` void`                                                                                                                                                                                                                | ` `[loadSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#loadSdk(java.lang.String,%20android.os.Bundle,%20java.util.concurrent.Executor,%20android.os.OutcomeReceiver<android.app.sdksandbox.SandboxedSdk,android.app.sdksandbox.LoadSdkException>))`(`[String](https://developer.android.com/reference/java/lang/String)` sdkName, `[Bundle](https://developer.android.com/reference/android/os/Bundle)` params, `[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)` executor, `[OutcomeReceiver](https://developer.android.com/reference/android/os/OutcomeReceiver)`<`[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk)`, `[LoadSdkException](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/LoadSdkException)`> receiver) ` Loads SDK in an SDK sandbox java process. |
| ` `[IBinder](https://developer.android.com/reference/android/os/IBinder)                                                                                                                                               | ` `[registerSdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#registerSdkSandboxActivityHandler(android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler))`(`[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)` sdkSandboxActivityHandler) ` Returns an identifier for a[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)after registering it.                                                                                                                                                                                                                                                                                                                             |
| ` void`                                                                                                                                                                                                                | ` `[unregisterSdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#unregisterSdkSandboxActivityHandler(android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler))`(`[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)` sdkSandboxActivityHandler) ` Unregister an already registered[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler).                                                                                                                                                                                                                                                                                                                                        |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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

### SDK_SANDBOX_CONTROLLER_SERVICE

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in[Ad Services Extensions 5](https://developer.android.com/sdkExtensions)  

```
public static final String SDK_SANDBOX_CONTROLLER_SERVICE
```

<br />

<br />

Constant Value: "sdk_sandbox_controller_service"

## Public methods

### getAppOwnedSdkSandboxInterfaces

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public List<AppOwnedSdkSandboxInterface> getAppOwnedSdkSandboxInterfaces ()
```

Fetches all[AppOwnedSdkSandboxInterface](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/AppOwnedSdkSandboxInterface)that are registered by the app.

<br />

|                                                                                                                                                                                                                                    Returns                                                                                                                                                                                                                                     ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [List](https://developer.android.com/reference/java/util/List)`<`[AppOwnedSdkSandboxInterface](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/AppOwnedSdkSandboxInterface)`>` | List of[AppOwnedSdkSandboxInterface](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/AppOwnedSdkSandboxInterface)containing all currently registered AppOwnedSdkSandboxInterface. This value cannot be`null`. <br /> |

|                                                                                                                                                                             Throws                                                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if the controller is obtained from an unexpected context. Use[SandboxedSdkProvider#getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext())for the right context |

### getClientPackageName

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public String getClientPackageName ()
```

Returns the package name of the client app.

<br />

|                                                Returns                                                 ||
|--------------------------------------------------------------------|------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | This value cannot be`null`. <br /> |

|                                                                                                                                                                              Throws                                                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if the controller is obtained from an unexpected context. Use[SandboxedSdkProvider#getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext())for the right context. |

### getClientSharedPreferences

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in[Ad Services Extensions 5](https://developer.android.com/sdkExtensions)  

```
public SharedPreferences getClientSharedPreferences ()
```

Returns[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences)containing data synced from the client app.

Keys that have been synced by the client app using[SdkSandboxManager.addSyncedSharedPreferencesKeys(Set)](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SdkSandboxManager#addSyncedSharedPreferencesKeys(java.util.Set<java.lang.String>))can be found in this[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences).

The returned[SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences)should only be read. Writing to it is not supported.

<br />

|                                                                                                                                 Returns                                                                                                                                  ||
|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences) | [SharedPreferences](https://developer.android.com/reference/android/content/SharedPreferences)containing data synced from client app. This value cannot be`null`. <br /> |

|                                                                                                                                                                             Throws                                                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if the controller is obtained from an unexpected context. Use[SandboxedSdkProvider#getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext())for the right context |

### getSandboxedSdks

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in[Ad Services Extensions 5](https://developer.android.com/sdkExtensions)  

```
public List<SandboxedSdk> getSandboxedSdks ()
```

Fetches information about Sdks that are loaded in the sandbox.

<br />

|                                                                                                                                                                                        Returns                                                                                                                                                                                         ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [List](https://developer.android.com/reference/java/util/List)`<`[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk)`>` | List of[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk)containing all currently loaded sdks This value cannot be`null`. <br /> |

|                                                                                                                                                                             Throws                                                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if the controller is obtained from an unexpected context. Use[SandboxedSdkProvider#getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext())for the right context |

### loadSdk

[**Added in Android UpsideDownCakePrivacySandbox**](https://developer.android.com/preview)  

```
public void loadSdk (String sdkName, 
                Bundle params, 
                Executor executor, 
                OutcomeReceiver<SandboxedSdk, LoadSdkException> receiver)
```

Loads SDK in an SDK sandbox java process.

Loads SDK library with`sdkName`to an SDK sandbox process asynchronously. The caller will be notified through the`receiver`.

The caller may only load`SDKs`the client app depends on into the SDK sandbox.

<br />

|                                                                                                                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                                                                                                                          ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sdkName`  | `String`: name of the SDK to be loaded. This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `params`   | `Bundle`: additional parameters to be passed to the SDK in the form of a[Bundle](https://developer.android.com/reference/android/os/Bundle)as agreed between the client and the SDK. This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `executor` | `Executor`: the[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)on which to invoke the receiver. This value cannot be`null`. Callback and listener events are dispatched through this[Executor](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[Context.getMainExecutor()](https://developer.android.com/reference/android/content/Context#getMainExecutor()). Otherwise, provide an[Executor](https://developer.android.com/reference/java/util/concurrent/Executor)that dispatches to an appropriate thread. <br /> |
| `receiver` | `OutcomeReceiver`: This either receives a[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk)on a successful run, or[LoadSdkException](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/LoadSdkException). This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                   |

|                                                                                                                                                                             Throws                                                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if the controller is obtained from an unexpected context. Use[SandboxedSdkProvider#getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext())for the right context |

### registerSdkSandboxActivityHandler

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in[Ad Services Extensions 7](https://developer.android.com/sdkExtensions)  

```
public IBinder registerSdkSandboxActivityHandler (SdkSandboxActivityHandler sdkSandboxActivityHandler)
```

Returns an identifier for a[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)after registering it.

This function registers an implementation of[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)created by an SDK and returns an[IBinder](https://developer.android.com/reference/android/os/IBinder)which uniquely identifies the passed[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)object.

If the same[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)registered multiple times without unregistering, the same[IBinder](https://developer.android.com/reference/android/os/IBinder)token will be returned.

<br />

|                                                                                                                               Parameters                                                                                                                               ||
|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sdkSandboxActivityHandler` | `SdkSandboxActivityHandler`: is the[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)to register. This value cannot be`null`. <br /> |

|                                                                                                                                                                               Returns                                                                                                                                                                               ||
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IBinder](https://developer.android.com/reference/android/os/IBinder) | [IBinder](https://developer.android.com/reference/android/os/IBinder)uniquely identify the passed[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler). This value cannot be`null`. <br /> |

### unregisterSdkSandboxActivityHandler

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in[Ad Services Extensions 7](https://developer.android.com/sdkExtensions)  

```
public void unregisterSdkSandboxActivityHandler (SdkSandboxActivityHandler sdkSandboxActivityHandler)
```

Unregister an already registered[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler).

If the passed[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)is registered, it will be unregistered. Otherwise, it will do nothing.

After unregistering, SDK can register the same handler object again or create a new one in case it wants a new[Activity](https://developer.android.com/reference/android/app/Activity).

If the[IBinder](https://developer.android.com/reference/android/os/IBinder)token of the unregistered handler used to start a[Activity](https://developer.android.com/reference/android/app/Activity), the[Activity](https://developer.android.com/reference/android/app/Activity)will fail to start.

<br />

|                                                                                                                                Parameters                                                                                                                                ||
|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sdkSandboxActivityHandler` | `SdkSandboxActivityHandler`: is the[SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler)to unregister. This value cannot be`null`. <br /> |

|                  Returns                   ||
|--------|------------------------------------|
| `void` | This value cannot be`null`. <br /> |