App State Observer
Observes application process lifecycle (foreground/background) and manages reconnection behavior and cleanup using ProcessLifecycleOwner for reliable app-level state detection.
Functions
Link copied to clipboard
Initialize the observer by registering it with ProcessLifecycleOwner Must be called from main thread as ProcessLifecycleOwner requires it
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Called when app process moves to foreground (ProcessLifecycleOwner.onStart) Handles reconnection and re-enabling of auto-reconnect after cleanup
Link copied to clipboard
Called when app process moves to background (ProcessLifecycleOwner.onStop) Triggers cleanup to prevent non-daemon threads from blocking JVM shutdown (ANR prevention)