Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Firestore: When do I have to remove SnapshotListeners?

I am working on an Android App and a few of my activities are listening to a Firestore-Database with the help of the function addSnapshotListener. When an activity that called the addSnapshotListener function gets finished (by calling finish() or pressing the back button): Is the listener removed automatically or do I have to call the remove() method myself?

And what happens when I start another activity? Is the SnapshotListner of the previous activity still active or is it paused?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Firestore never automatically removes listeners and is not aware of your app’s activity lifecycle. You have to remove them yourself.

The only time a listener is automatically removed is when your application’s process is terminated – all of its code ceases to run at that point.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading