According to the Android developer documentation on Lifecycle:
If you use Java 7 Language, Lifecycle events are observed using annotations. Once Java 8 Language becomes mainstream on Android, annotations will be deprecated, so between
DefaultLifecycleObserver
and annotations, you must always preferDefaultLifecycleObserver
.
class TestObserver implements DefaultLifecycleObserver {
@Override
public void onCreate(LifecycleOwner owner) {
// your code
}
}
What specific Java 8 language/jvm features are driving the deprecation of the Lifecycle annotations? For example, do we get better performance (build or runtime) when using the DefaultLifecycleObserver
?