Here is the scenario -:
A firebase reference is created
Firebase myRef = new Firebase(url) // In Main Activity
User Clicks a button navigates to other activity .
onPause() for Main activity is called.Is there a way to destroy this constructor ?
This reference is creating some unexpected behavior. Simply calling finish() for Main activity will destroy it or not?
Firebase
objects are lightweight references to locations in your Firebase Database. There is no need (nor ability) to manage their life-cycle. So as @dex commented, you can just let the Java garbage collector take care of them.
On the other hand, once you start attaching listeners (e.g. addValueEventListener()
) you should detach them in the corresponding life-cycle event with removeEventListener()
. Also see Firebase adding listeners in adapters in Android and How stop Listening to firebase location in android
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With