Skip to content

Instantly share code, notes, and snippets.

@pyeongho
Created March 13, 2020 01:50
Show Gist options
  • Save pyeongho/5a3a3bcfa25b9b85e1dd4c3a6d474c2b to your computer and use it in GitHub Desktop.
Save pyeongho/5a3a3bcfa25b9b85e1dd4c3a6d474c2b to your computer and use it in GitHub Desktop.
class OnAppObserver : LifecycleObserver {
companion object {
var APP_STATUS: AppStatus = AppStatus.NOTEXECUTE
}
enum class AppStatus {
NOTEXECUTE,
BACKGROUND,
FOREGROUND
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onStart() {
APP_STATUS = AppStatus.FOREGROUND
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun onStop() {
APP_STATUS = AppStatus.BACKGROUND
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment