Hi everyone, I’m curious what the correct approach...
# android
c
Hi everyone, I’m curious what the correct approach is when implementing
LifecycleObserver
. The Kotlin examples here use `@OnLifecycleEvent`: https://developer.android.com/topic/libraries/architecture/lifecycle#lc However, this page (Java examples) says that annotations will be deprecated: https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle , and instead I should implement
DefaultLifecycleObserver
What is the correct practice here? Thank you!
For reference I am using Java 11
j
"If you use Java 8 Language, then observe events with 
DefaultLifecycleObserver
. To include it you should add 
"androidx.lifecycle:lifecycle-common-java8:<version>"
 to your build.gradle file."