DefaultLifecycleObserver や LifecycleEventObserver の使い方

あら。

DefaultLifecycleObserver や LifecycleEventObserver の使い方

Annotation that can be used to mark methods on LifecycleObserver implementations that should be invoked to handle lifecycle events.

Deprecated
This annotation required the usage of code generation or reflection, which should be avoided. Use DefaultLifecycleObserver or LifecycleEventObserver instead.

いつのまにか deprecated。

言われる通りに代わりのやつらを使います。

👉 DefaultLifecycleObserver  |  Android Developers 

👉 LifecycleEventObserver  |  Android Developers 

昔のコードを久々に開くといろいろな新しい発見があります。

👉 android - Do I need to call removeObserver for lifecycle, upon its onDestroy() event? - Stack Overflow 
👉 JakeWharton/timber: A logger with a small, extensible API which provides utility on top of Android's normal Log class. 


関連ワード:  AndroidKotlinおすすめライブラリ開発