I was recently working with firebase, and i needed a way to store and use a single firebase instance and its event listener across all other activities/fragments.
I am not much good with java , but i know this : when a class extends another class, the parent class’s constructor and the overriden functions would be called when child class constructor/ functions are called.
But what happens when an activity is referenced from a base class? how will their lifecycles be affected? what will happen if say firebase instance is initialised in Base Activity’s
onResume but referred in child activity’s
onStart()? What happens when multiple activity’s are referencing a base activity?Because When i open Activity B( extending parent activity X) from Activity A(extending parent activity Y), would they be calling the same activity X? I feel stupid and deeply confused. Also, how is the approach of using an Base Class different from using an Application class for storing firebase and other shared variables?