SdkActivityLaunchers

Added in 1.0.0-alpha02

public final class SdkActivityLaunchers


Summary

Public methods

static final @NonNull LocalManagedSdkActivityLauncher<@NonNull T>
<T extends Activity & LifecycleOwner> createManagedSdkActivityLauncher(
    @NonNull T receiver,
    @NonNull Function0<@NonNull Boolean> allowLaunch
)

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

static final @NonNull LocalUnmanagedSdkActivityLauncher<@NonNull T>
<T extends Activity> createUnmanagedSdkActivityLauncher(
    @NonNull T receiver,
    @NonNull Function0<@NonNull Boolean> allowLaunch
)

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

static final @NonNull Bundle

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

Public methods

createManagedSdkActivityLauncher

public static final @NonNull LocalManagedSdkActivityLauncher<@NonNull T> <T extends Activity & LifecycleOwner> createManagedSdkActivityLauncher(
    @NonNull T receiver,
    @NonNull Function0<@NonNull Boolean> allowLaunch
)

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 extends 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'.

@NonNull Function0<@NonNull Boolean> allowLaunch

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

public static final @NonNull LocalUnmanagedSdkActivityLauncher<@NonNull T> <T extends Activity> createUnmanagedSdkActivityLauncher(
    @NonNull T receiver,
    @NonNull Function0<@NonNull Boolean> allowLaunch
)

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 extends 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'.

@NonNull Function0<@NonNull Boolean> allowLaunch

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

public static final @NonNull Bundle toLauncherInfo(@NonNull SdkActivityLauncher receiver)

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