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)  

# SdkSandboxActivityHandler


`
public


interface
SdkSandboxActivityHandler
`


`


`

|--------------------------------------------------------------|
| android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler |

<br />

*** ** * ** ***

This is used to notify the SDK when an [Activity](https://developer.android.com/reference/android/app/Activity) is created for it.

When an SDK wants to start an [Activity](https://developer.android.com/reference/android/app/Activity), it should register an implementation of this
class by calling [SdkSandboxController.registerSdkSandboxActivityHandler(android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler)](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxController#registerSdkSandboxActivityHandler(android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler)) that will
return an [IBinder](https://developer.android.com/reference/android/os/IBinder) identifier for the registered [SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler) to The SDK.

The SDK should be notified about the [Activity](https://developer.android.com/reference/android/app/Activity) creation by calling [onActivityCreated(android.app.Activity)](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler#onActivityCreated(android.app.Activity)) which happens when the caller app calls
[SdkSandboxManager.startSdkSandboxActivity(Activity, IBinder)](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/SdkSandboxManager#startSdkSandboxActivity(android.app.Activity,%20android.os.IBinder)) using
the same [IBinder](https://developer.android.com/reference/android/os/IBinder) identifier for the registered [SdkSandboxActivityHandler](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler).

## Summary

|                                                                                                                                                                                                ### Public methods                                                                                                                                                                                                ||
|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void` | ` `[onActivityCreated](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler#onActivityCreated(android.app.Activity))`(`[Activity](https://developer.android.com/reference/android/app/Activity)` activity) ` Notifies SDK when an [Activity](https://developer.android.com/reference/android/app/Activity) gets created. |

## Public methods

### onActivityCreated

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 abstract void onActivityCreated (Activity activity)
```

Notifies SDK when an [Activity](https://developer.android.com/reference/android/app/Activity) gets created.

This function is called synchronously from the main thread of the [Activity](https://developer.android.com/reference/android/app/Activity) that is
getting created.

SDK is expected to call [Activity#setContentView(View)](https://developer.android.com/reference/android/app/Activity#setContentView(android.view.View)) to the passed [Activity](https://developer.android.com/reference/android/app/Activity) object to populate the view.

If SDK registers lifecycle callbacks over the passed [Activity](https://developer.android.com/reference/android/app/Activity) object using [Activity.registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks)](https://developer.android.com/reference/android/app/Activity#registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks)), it is important to note that [Application.ActivityLifecycleCallbacks.onActivityPreCreated(Activity, Bundle)](https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks#onActivityPreCreated(android.app.Activity,%20android.os.Bundle))
and [Application.ActivityLifecycleCallbacks.onActivityCreated(Activity, Bundle)](https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks#onActivityCreated(android.app.Activity,%20android.os.Bundle)) will not be triggered as [onActivityCreated(android.app.Activity)](https://developer.android.com/design-for-safety/privacy-sandbox/reference/sdksandbox/sdkprovider/SdkSandboxActivityHandler#onActivityCreated(android.app.Activity)) is called at the
[Activity](https://developer.android.com/reference/android/app/Activity) creation stage. Then to know about the Activity state, SDKs should override
[Application.ActivityLifecycleCallbacks.onActivityPostCreated(Activity, Bundle)](https://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks#onActivityPostCreated(android.app.Activity,%20android.os.Bundle)).

<br />

|                                                                      Parameters                                                                       ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `activity` | `Activity`: the [Activity](https://developer.android.com/reference/android/app/Activity) gets created This value cannot be `null`. <br /> |