I have 2 activities : ActivityA and ActivityB.
When application go to background I want to detect which Activity has just been on foreground.
For example :
Activity A is in foreground -> Click home button -> App go to background
onBackground: ActivityA
Activity B is in foreground -> Click home button -> App go to background
onBackground: ActivityB
I confused about ProcessLifecycleObserver
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onEnterForeground() {
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun onEnterBackground() {
}
because of can not detect which Activity here ?
And when I try to use ActivityLifecycleCallbacks
it's activity lifecycle , not application lifecycle so background state can not detected here.
Does any one has solution for that case ?