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

# SandboxedSdkProvider

`
public


abstract
class
SandboxedSdkProvider
`  
`

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


``


`

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

<br />

*** ** * ** ***

Encapsulates API which SDK sandbox can use to interact with SDKs loaded into it.

SDK has to implement this abstract class to generate an entry point for SDK sandbox to be able to call it through.

## Summary

|                                                                       ### Public constructors                                                                       ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[SandboxedSdkProvider](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#SandboxedSdkProvider())`() ` |

|                                                                                                                                                                                                                                                                                                                     ### Public methods                                                                                                                                                                                                                                                                                                                     ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final void`                                                                                                                 | ` `[attachContext](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#attachContext(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context)` context) ` Sets the SDK[Context](https://developer.android.com/reference/android/content/Context)which can then be received using[getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext()). |
| ` void`                                                                                                                       | ` `[beforeUnloadSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#beforeUnloadSdk())`() ` Does the work needed for the SDK to free its resources before being unloaded.                                                                                                                                                                                                                                                                                        |
| ` final `[Context](https://developer.android.com/reference/android/content/Context)                                           | ` `[getContext](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext())`() ` Return the[Context](https://developer.android.com/reference/android/content/Context)previously set through[SandboxedSdkProvider#attachContext](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#attachContext(android.content.Context)).                                                                              |
| ` abstract `[View](https://developer.android.com/reference/android/view/View)                                                 | ` `[getView](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getView(android.content.Context,%20android.os.Bundle,%20int,%20int))`(`[Context](https://developer.android.com/reference/android/content/Context)` windowContext, `[Bundle](https://developer.android.com/reference/android/os/Bundle)` params, int width, int height) ` Requests a view to be remotely rendered to the client app process.                                                          |
| ` abstract `[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk) | ` `[onLoadSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#onLoadSdk(android.os.Bundle))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` params) ` Does the work needed for the SDK to start handling requests.                                                                                                                                                                                                                        |

| ### 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*.                                                                                             | ||

## Public constructors

### SandboxedSdkProvider

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

```
public SandboxedSdkProvider ()
```

<br />

<br />

## Public methods

### attachContext

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

```
public final void attachContext (Context context)
```

Sets the SDK[Context](https://developer.android.com/reference/android/content/Context)which can then be received using[getContext()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext()). This is called before[onLoadSdk(Bundle)](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#onLoadSdk(android.os.Bundle))is invoked. No operations requiring a[Context](https://developer.android.com/reference/android/content/Context)should be performed before then, as[SandboxedSdkProvider#getContext](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#getContext())will return null until this method has been called.

Throws IllegalStateException if a base context has already been set.

<br />

|                                   Parameters                                   ||
|-----------|---------------------------------------------------------------------|
| `context` | `Context`: The new base context. This value cannot be`null`. <br /> |

### beforeUnloadSdk

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

```
public void beforeUnloadSdk ()
```

Does the work needed for the SDK to free its resources before being unloaded.

This function is called by the SDK sandbox manager before it unloads the SDK. The SDK should fail any invocations on the Binder previously returned to the client through[SandboxedSdk.getInterface()](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk#getInterface()).

The SDK should not do any long-running tasks here, like I/O and network calls.

<br />

### getContext

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

```
public final Context getContext ()
```

Return the[Context](https://developer.android.com/reference/android/content/Context)previously set through[SandboxedSdkProvider#attachContext](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdkProvider#attachContext(android.content.Context)). This will return null if no context has been previously set.

<br />

|                                      Returns                                       ||
|----------------------------------------------------------------------------|--------|
| [Context](https://developer.android.com/reference/android/content/Context) | <br /> |

### getView

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

```
public abstract View getView (Context windowContext, 
                Bundle params, 
                int width, 
                int height)
```

Requests a view to be remotely rendered to the client app process.

Returns[View](https://developer.android.com/reference/android/view/View)will be wrapped into[SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage). the resulting[SurfacePackage](https://developer.android.com/reference/android/view/SurfaceControlViewHost.SurfacePackage)will be sent back to the client application.

The SDK should not do any long-running tasks here, like I/O and network calls. Doing so can prevent the SDK from receiving requests from the client.

<br />

|                                                                                       Parameters                                                                                        ||
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `windowContext` | `Context`: the[Context](https://developer.android.com/reference/android/content/Context)of the display which meant to show the view This value cannot be`null`. <br /> |
| `params`        | `Bundle`: list of params passed from the client application requesting the view This value cannot be`null`. <br />                                                     |
| `width`         | `int`: The view returned will be laid as if in a window of this width, in pixels. <br />                                                                               |
| `height`        | `int`: The view returned will be laid as if in a window of this height, in pixels. <br />                                                                              |

|                                                                                                                   Returns                                                                                                                    ||
|-------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [View](https://developer.android.com/reference/android/view/View) | a[View](https://developer.android.com/reference/android/view/View)which SDK sandbox pass to the client application requesting the view This value cannot be`null`. <br /> |

### onLoadSdk

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

```
public abstract SandboxedSdk onLoadSdk (Bundle params)
```

Does the work needed for the SDK to start handling requests.

This function is called by the SDK sandbox after it loads the SDK.

SDK should do any work to be ready to handle upcoming requests. It should not do any long-running tasks here, like I/O and network calls. Doing so can prevent the SDK from receiving requests from the client. Additionally, it should not do initialization that depends on other SDKs being loaded into the SDK sandbox.

The SDK should not do any operations requiring a[Context](https://developer.android.com/reference/android/content/Context)object before this method has been called.

<br />

|                                                               Parameters                                                               ||
|----------|------------------------------------------------------------------------------------------------------------------------------|
| `params` | `Bundle`: list of params passed from the client when it loads the SDK. This can be empty. This value cannot be`null`. <br /> |

|                                                                                                                                                                                                                                                       Returns                                                                                                                                                                                                                                                       ||
|-------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk) | Returns a[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk), passed back to the client. The IBinder used to create the[SandboxedSdk](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SandboxedSdk)object will be used by the client to call into the SDK. This value cannot be`null`. <br /> |

|                                                            Throws                                                            ||
|---------------------------------------------------------------------------------------------------------------------------|---|
| [LoadSdkException](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/LoadSdkException) |   |