Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2019-12-30:什么是Lifecycle?请分析其内部原理和使用场景? #222

Open
Moosphan opened this issue Dec 30, 2019 · 4 comments

Comments

@Moosphan
Copy link
Owner

No description provided.

@zhangandroid
Copy link

一个管理Activity生命周期的一个抽象类,里面封装了activity的生命周期的方法,一般我们会在基类中绑定当前Activity生命周期
---->>它通过观察者模式+注解来让我们更方便的监听Activity和Fragment的生命周期变化

@liuhuiAndroid
Copy link

Jetpack 的 Lifecycle 库:它可以有效的避免内存泄漏,解决 Android 生命周期的常见难题。
内部原理:ComponentActivity 的 onCreate 方法中注入了 ReportFragment,通过 Fragment 来实现生命周期监听。
使用场景:给 RecyclerView 的 ViewHolder 添加 Lifecycle 的能力。自己实现 LifecycleHandler,在 Activity 销毁的时候,自动移除 Handler 的消息避免 Handler 导致的内存泄漏。

@mlinqirong
Copy link

Lifecycle是用于管理Activity和Fragment 生命周期监听 里面封装了生命周期的方法
内部通过观察者模式和注解方法来实现生命周期监听
Lifecycle降低模块间的耦合度,并降低内存泄漏发生的可能性

@senlinxuefeng
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants