Aris Papadopoulos
Aug 22, 2017 · 1 min read

Hi Mohan, that’s indeed a very reasonable question to ask. I kind of missed it since I am working 0n a keyboard, which means no Activities and therefore less things to worry about.

But still, little would change if we were talking about a normal app with Activities. We would typically subscribe in Application.onCreate and we actually want the trackers to be active in all times that the application is alive, so there’s no need to unsubscribe: the trackers contain no state, so they are lightweight, and they hold no references to a Context so there’s no problem with keeping them alive throughout.

In theory you could subscribe and unsubscribe in all Activities onResume and onPause (or event better in Application.ActivityLifecycleCallbacks.onActivityResumed and Application.ActivityLifecycleCallbacks.onActivityPaused) but I think it’s unnecessary and brings no benefits.

)
    Aris Papadopoulos

    Written by

    Android Software Engineer. RxJava, Kotlin, SOLID, Clean code, Clean Architecture and other cool stuff.