Stay organized with collections
Save and categorize content based on your preferences.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# SdkSandboxActivityHandler\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [Ad Services Extensions 7](/sdkExtensions) \n\nSdkSandboxActivityHandler\n=========================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/app/sdksandbox/sdkprovider/SdkSandboxActivityHandler \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nSdkSandboxActivityHandler\n`\n\n\n`\n\n\n`\n\n|--------------------------------------------------------------|\n| android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis is used to notify the SDK when an [Activity](/reference/android/app/Activity) is created for it.\n\nWhen an SDK wants to start an [Activity](/reference/android/app/Activity), it should register an implementation of this\nclass by calling [SdkSandboxController.registerSdkSandboxActivityHandler(android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler)](/reference/android/app/sdksandbox/sdkprovider/SdkSandboxController#registerSdkSandboxActivityHandler(android.app.sdksandbox.sdkprovider.SdkSandboxActivityHandler)) that will\nreturn an [IBinder](/reference/android/os/IBinder) identifier for the registered [SdkSandboxActivityHandler](/reference/android/app/sdksandbox/sdkprovider/SdkSandboxActivityHandler) to The SDK.\n\nThe SDK should be notified about the [Activity](/reference/android/app/Activity) creation by calling [onActivityCreated(android.app.Activity)](/reference/android/app/sdksandbox/sdkprovider/SdkSandboxActivityHandler#onActivityCreated(android.app.Activity)) which happens when the caller app calls\n[SdkSandboxManager.startSdkSandboxActivity(Activity, IBinder)](/reference/android/app/sdksandbox/SdkSandboxManager#startSdkSandboxActivity(android.app.Activity,%20android.os.IBinder)) using\nthe same [IBinder](/reference/android/os/IBinder) identifier for the registered [SdkSandboxActivityHandler](/reference/android/app/sdksandbox/sdkprovider/SdkSandboxActivityHandler).\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onActivityCreated](/reference/android/app/sdksandbox/sdkprovider/SdkSandboxActivityHandler#onActivityCreated(android.app.Activity))`(`[Activity](/reference/android/app/Activity)` activity) ` Notifies SDK when an [Activity](/reference/android/app/Activity) gets created. |\n\nPublic methods\n--------------\n\n### onActivityCreated\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nAlso in [Ad Services Extensions 7](/sdkExtensions) \n\n```\npublic abstract void onActivityCreated (Activity activity)\n```\n\nNotifies SDK when an [Activity](/reference/android/app/Activity) gets created.\n\nThis function is called synchronously from the main thread of the [Activity](/reference/android/app/Activity) that is\ngetting created.\n\nSDK is expected to call [Activity.setContentView(View)](/reference/android/app/Activity#setContentView(android.view.View)) to the passed [Activity](/reference/android/app/Activity) object to populate the view.\n\nIf SDK registers lifecycle callbacks over the passed [Activity](/reference/android/app/Activity) object using [Activity.registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks)](/reference/android/app/Activity#registerActivityLifecycleCallbacks(android.app.Application.ActivityLifecycleCallbacks)), it is important to note that [Application.ActivityLifecycleCallbacks.onActivityPreCreated(Activity, Bundle)](/reference/android/app/Application.ActivityLifecycleCallbacks#onActivityPreCreated(android.app.Activity,%20android.os.Bundle))\nand [Application.ActivityLifecycleCallbacks.onActivityCreated(Activity, Bundle)](/reference/android/app/Application.ActivityLifecycleCallbacks#onActivityCreated(android.app.Activity,%20android.os.Bundle)) will not be triggered as [onActivityCreated(android.app.Activity)](/reference/android/app/sdksandbox/sdkprovider/SdkSandboxActivityHandler#onActivityCreated(android.app.Activity)) is called at the\n[Activity](/reference/android/app/Activity) creation stage. Then to know about the Activity state, SDKs should override\n[Application.ActivityLifecycleCallbacks.onActivityPostCreated(Activity, Bundle)](/reference/android/app/Application.ActivityLifecycleCallbacks#onActivityPostCreated(android.app.Activity,%20android.os.Bundle)).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|--------------------------------------------------------------------------------------------------------------|\n| `activity` | `Activity`: the [Activity](/reference/android/app/Activity) gets created This value cannot be `null`. \u003cbr /\u003e |"]]