Skip to content Skip to sidebar Skip to footer

Removing Continuous Firebase Listeners On Fragment Change

Each Fragment in my application has their own set of continuous Firebase listeners. These become unnecessary once the active Fragment has changed, however, the listeners continue i

Solution 1:

You need to remove the listener accordingly to the life-cycle of your fragment.

If you have added the listener in onStart you have to remove it in onStop. If you have added the listener in onResume you have to remove it in onPause. If you have added the listener in onCreate you have to remove it in onDestroy. But remember onDestroy is not always called.


Post a Comment for "Removing Continuous Firebase Listeners On Fragment Change"