T
- a class of the activity which is under control by this class.public class ActivityController<T extends Activity> extends ComponentController<ActivityController<T>,T>
Using ActivityController directly from your tests is strongly discouraged. You have to call
all the lifecycle callback methods (create, postCreate, start, ...) in the same manner as the
Android framework by yourself otherwise you'll see fidelity issues. Consider using androidx.test.core.app.ActivityScenario
instead, which provides higher-level, streamlined APIs
to control the lifecycle and it works with instrumentation tests too.
attached, component, intent, myself, shadowMainLooper
Modifier and Type | Method | Description |
---|---|---|
ActivityController<T> |
configurationChange() |
Applies the current system configuration to the Activity.
|
ActivityController<T> |
configurationChange(Configuration newConfiguration) |
Performs a configuration change on the Activity.
|
ActivityController<T> |
create() |
|
ActivityController<T> |
create(Bundle bundle) |
|
ActivityController<T> |
destroy() |
|
ActivityController<T> |
newIntent(Intent intent) |
|
static <T extends Activity> |
of(T activity) |
|
static <T extends Activity> |
of(T activity,
Intent intent) |
|
ActivityController<T> |
pause() |
|
ActivityController<T> |
postCreate(Bundle bundle) |
|
ActivityController<T> |
postResume() |
|
ActivityController<T> |
recreate() |
Recreates activity instance which is controlled by this ActivityController.
|
ActivityController<T> |
restart() |
|
ActivityController<T> |
restoreInstanceState(Bundle bundle) |
|
ActivityController<T> |
resume() |
|
ActivityController<T> |
saveInstanceState(Bundle outState) |
|
ActivityController<T> |
setup() |
Calls the same lifecycle methods on the Activity called by Android the first time the Activity is created.
|
ActivityController<T> |
setup(Bundle savedInstanceState) |
Calls the same lifecycle methods on the Activity called by Android when an Activity is restored
from previously saved state.
|
ActivityController<T> |
start() |
|
ActivityController<T> |
stop() |
|
ActivityController<T> |
userLeaving() |
|
ActivityController<T> |
visible() |
|
ActivityController<T> |
windowFocusChanged(boolean hasFocus) |
get, getIntent, invokeWhilePaused
public static <T extends Activity> ActivityController<T> of(T activity, Intent intent)
public static <T extends Activity> ActivityController<T> of(T activity)
public ActivityController<T> create(@Nullable Bundle bundle)
public ActivityController<T> create()
create
in class ComponentController<ActivityController<T extends Activity>,T extends Activity>
public ActivityController<T> restart()
public ActivityController<T> start()
public ActivityController<T> restoreInstanceState(Bundle bundle)
public ActivityController<T> postCreate(@Nullable Bundle bundle)
public ActivityController<T> resume()
public ActivityController<T> postResume()
public ActivityController<T> visible()
public ActivityController<T> windowFocusChanged(boolean hasFocus)
public ActivityController<T> userLeaving()
public ActivityController<T> pause()
public ActivityController<T> saveInstanceState(Bundle outState)
public ActivityController<T> stop()
public ActivityController<T> destroy()
destroy
in class ComponentController<ActivityController<T extends Activity>,T extends Activity>
public ActivityController<T> setup()
public ActivityController<T> setup(@Nullable Bundle savedInstanceState)
savedInstanceState
- Saved instance state.public ActivityController<T> newIntent(Intent intent)
public ActivityController<T> configurationChange()
This can be used in conjunction with RuntimeEnvironment.setQualifiers(String)
to
simulate configuration changes.
If the activity is configured to handle changes without being recreated, Activity.onConfigurationChanged(Configuration)
will be called. Otherwise, the activity is
recreated as described here.
public ActivityController<T> configurationChange(Configuration newConfiguration)
If the activity is configured to handle changes without being recreated, Activity.onConfigurationChanged(Configuration)
will be called. Otherwise, the activity is
recreated as described here.
newConfiguration
- The new configuration to be set.public ActivityController<T> recreate()