The recommended way to do this is to use ActivityScenario https://developer.android.com/reference/androidx/test/core/app/ActivityScenario