ActivityScenarioKt


public final class ActivityScenarioKt


Summary

Public methods

static final @NonNull ActivityScenario<@NonNull A>
<A extends Activity> launchActivity(Intent intent, Bundle activityOptions)

Launches an activity of a given class and constructs ActivityScenario with the activity.

static final @NonNull ActivityScenario<@NonNull A>
<A extends Activity> launchActivityForResult(
    Intent intent,
    Bundle activityOptions
)

Launches an activity of a given class and constructs ActivityScenario with the activity.

Public methods

launchActivity

public static final @NonNull ActivityScenario<@NonNull A> <A extends Activity> launchActivity(Intent intent, Bundle activityOptions)

Launches an activity of a given class and constructs ActivityScenario with the activity. Waits for the lifecycle state transitions to be complete.

Normally this would be State.RESUMED, but may be another state.

This method cannot be called from the main thread except in Robolectric tests.

Parameters
Intent intent

an intent to start activity or null to use the default one

Bundle activityOptions

an activity options bundle to be passed along with the intent to start activity

Returns
@NonNull ActivityScenario<@NonNull A>

ActivityScenario which you can use to make further state transitions

Throws
kotlin.AssertionError

if the lifecycle state transition never completes within the timeout

launchActivityForResult

public static final @NonNull ActivityScenario<@NonNull A> <A extends Activity> launchActivityForResult(
    Intent intent,
    Bundle activityOptions
)

Launches an activity of a given class and constructs ActivityScenario with the activity. Waits for the lifecycle state transitions to be complete. Broadcasts activity result.

Normally this would be State.RESUMED, but may be another state.

This method cannot be called from the main thread except in Robolectric tests.

Parameters
Intent intent

an intent to start activity or null to use the default one

Bundle activityOptions

an activity options bundle to be passed along with the intent to start activity

Returns
@NonNull ActivityScenario<@NonNull A>

ActivityScenario which you can use to make further state transitions

Throws
kotlin.AssertionError

if the lifecycle state transition never completes within the timeout