I am using EventBus in my Android application. Is it a good idea to do a Eventbus.getDefault().register(this)
in my Application.onCreate()
? I don't have any UI updates to be made. I am trying this to make sure that I receive the subscription data even if the app goes to background. There might be other ways to achieve what I want, but I am curious if anything is wrong with this approach.
My doubts are :
Will this cause some kind of memory leak ? Eventbus is referencing the Application object, and the Application object is also relying on Eventbus. This looks cyclic.
When to unregister ? Application.onTerminate() is not guaranteed to be called. If #1 is not an issue, I guess it's fine to ignore unsubscribe in Application class.