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

Should I add snapshotListener inside onResume or onStart?

According to Firestore documentation, we can simply add and remove snapshotListener automatically just by passing the instance of Activity to the snapshotListener. But the snapshotListener can only be removed onStop. onStop is not guarantee to be called all the time. Should I add/remove my snapshotListener onResume/onPause instead?

>Solution :

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

If you’re not satisfied with when the automatic cancelation of snapshot listeners happen when you pass an Activity when registering them, you can instead manage the listener lifecycle yourself. There is nothing wrong with this, and is in fact what I usually do.

There is no singular correct answer here. It all depends on your preferences and the requirements of your app.

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