Summary

In this chapter, we refreshed our knowledge on the lifecycle of Activities and Fragments. Later, we used this knowledge to build and explore a few cases of how a memory and a thread leak can occur. This way, we clearly saw that Observables have to be manually terminated if they are endless (such as Observable.interval()) because they will be the reason for such leaks.

Next, we learned how to use the RxLifecycle library to easily terminate Subscriptions that are part of an Activity by binding them to the lifecycle of the Activity. This way, we ensure that the Activity and its resources will never be leaked in a very straightforward and easy-to-use way.

Finally, we used a newly acquired RxLifecycle library to fix our code that fetches financial quote information from spawning multiple redundant threads and leaking Observables.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.58.194