1. When a network request is made in Androd, if a callback is made after the network request is completed, and the activity has been recycled, how to deal with it?
Inspect knowledge points:
- acitvity view relationship and life cycle & memory model li>
- How to prevent memory leaks (weak references, cancel requests, and callbacks)
Solve knowledge points:
- activity view life cycle https://www.jianshu.com/p/0a4cb44ce9d1
- acitvity view window relationship https://blog .csdn.net/freekiteyu/article/details/79408969
- The role of Context https://www.cnblogs.com/tsingke/p/9127758.html
- Weak reference experiment
view holds the reference of activity (content) by default, activity can be finished, but not Was destroyed;
- Kotlin implements callback cancellation through coroutines (binding activitylife cycle)
In experiment… p>