Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To generate an ActivityScenario that commences in the INITIALIZED or CREATED state in Android, you can use the following code:

ActivityScenario<MyActivity> scenario = ActivityScenario.launch(MyActivity.class);
scenario.moveToState(Lifecycle.State.CREATED);

This will launch the MyActivity and move it to the CREATED state. You can also use Lifecycle.State.INITIALIZED to move the activity to the INITIALIZED state.