Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

ApplicationLifecycleMonitor

public interface ApplicationLifecycleMonitor

androidx.test.runner.lifecycle.ApplicationLifecycleMonitor


Interface for tests to use when they need to be informed of the application lifecycle state.

Retrieve instances of the monitor thru ApplicationLifecycleMonitorRegistry.

Detecting these lifecycle states requires support from Instrumentation, therefore do not expect an instance to be present under any arbitrary instrumentation.

Summary

Public methods

abstract void addLifecycleCallback(ApplicationLifecycleCallback callback)

Adds a new callback that will be notified when lifecycle changes occur.

abstract void removeLifecycleCallback(ApplicationLifecycleCallback callback)

Removes a previously registered lifecycle callback.

Public methods

addLifecycleCallback

void addLifecycleCallback (ApplicationLifecycleCallback callback)

Adds a new callback that will be notified when lifecycle changes occur.

Implementors will not hold a strong ref to the callback, the code which registers callbacks is responsible for this. Code which registers callbacks should responsibly remove their callback when it is no longer needed.

Callbacks may be executed on the main thread of the application, and should take care not to block or otherwise perform expensive operations as it will directly impact the application.

Parameters
callback ApplicationLifecycleCallback: an ApplicationLifecycleCallback

removeLifecycleCallback

void removeLifecycleCallback (ApplicationLifecycleCallback callback)

Removes a previously registered lifecycle callback.

Parameters
callback ApplicationLifecycleCallback