androidx.privacysandbox.activity.client


Interfaces

LocalSdkActivityLauncher

Local version of SdkActivityLauncher that allows callers in the app process to dispose the launcher resources.

Classes

LocalManagedSdkActivityLauncher

Local implementation of a lifecycle-aware SDK Activity launcher.

LocalUnmanagedSdkActivityLauncher

Local implementation of an SDK Activity launcher.

Extension functions summary

LocalManagedSdkActivityLauncher<T>
<T : Activity & LifecycleOwner> T.createManagedSdkActivityLauncher(
    allowLaunch: () -> Boolean
)

Returns a lifecycle-aware SdkActivityLauncher that launches activities on behalf of an SDK by using this activity as a starting context.

LocalUnmanagedSdkActivityLauncher<T>
<T : Activity> T.createUnmanagedSdkActivityLauncher(
    allowLaunch: () -> Boolean
)

Returns a lifecycle-unaware SdkActivityLauncher that launches activities on behalf of an SDK by using this activity as a starting context.

Bundle

Returns a Bundle with the information necessary to recreate this launcher.

Extension functions

createManagedSdkActivityLauncher

fun <T : Activity & LifecycleOwner> T.createManagedSdkActivityLauncher(
    allowLaunch: () -> Boolean
): LocalManagedSdkActivityLauncher<T>

Returns a lifecycle-aware SdkActivityLauncher that launches activities on behalf of an SDK by using this activity as a starting context. The created launcher will be automatically disposed when the current activity is destroyed, with no additional work required.

Parameters
<T : Activity & LifecycleOwner>

the current LifecycleOwner activity from which new SDK activities will be launched. If this activity is destroyed, any further SDK activity launches will simply be ignored, and LocalManagedSdkActivityLauncher.launchSdkActivity will return 'false'.

allowLaunch: () -> Boolean

predicate called each time an activity is about to be launched by the SDK, the activity will only be launched if it returns true.

createUnmanagedSdkActivityLauncher

fun <T : Activity> T.createUnmanagedSdkActivityLauncher(
    allowLaunch: () -> Boolean
): LocalUnmanagedSdkActivityLauncher<T>

Returns a lifecycle-unaware SdkActivityLauncher that launches activities on behalf of an SDK by using this activity as a starting context. The created launcher will need to be manually disposed explicitly by the caller.

It is recommended to use a lifecycle-aware launcher created using createManagedSdkActivityLauncher instead. It is automatically disposed when the current activity is destroyed, making it less prone to memory leaks.

Parameters
<T : Activity>

the current activity from which new SDK activities will be launched. If this activity is destroyed any further SDK activity launches will simply be ignored, and LocalUnmanagedSdkActivityLauncher.launchSdkActivity will return 'false'.

allowLaunch: () -> Boolean

predicate called each time an activity is about to be launched by the SDK, the activity will only be launched if it returns true.

fun SdkActivityLauncher.toLauncherInfo(): Bundle

Returns a Bundle with the information necessary to recreate this launcher. Possibly in a different process.