AppStateObserver

Observes application process lifecycle (foreground/background) and manages reconnection behavior and cleanup using ProcessLifecycleOwner for reliable app-level state detection.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
suspend fun initialize(application: Application)

Initialize the observer by registering it with ProcessLifecycleOwner Must be called from main thread as ProcessLifecycleOwner requires it

Link copied to clipboard
open fun onCreate(owner: LifecycleOwner)
Link copied to clipboard
open fun onDestroy(owner: LifecycleOwner)
Link copied to clipboard
open fun onPause(owner: LifecycleOwner)
Link copied to clipboard
open fun onResume(owner: LifecycleOwner)
Link copied to clipboard
open override fun onStart(owner: LifecycleOwner)

Called when app process moves to foreground (ProcessLifecycleOwner.onStart) Handles reconnection and re-enabling of auto-reconnect after cleanup

Link copied to clipboard
open override fun onStop(owner: LifecycleOwner)

Called when app process moves to background (ProcessLifecycleOwner.onStop) Triggers cleanup to prevent non-daemon threads from blocking JVM shutdown (ANR prevention)