0

Firebase Listener - Android Studio- Java

Firebase listeners get triggered on 2 conditions: 1. When initialized 3. When a document is being updated I want my listener to be triggered only on the 2nd condition, how can I do it?

19th Dec 2022, 1:00 PM
Yahel
Yahel - avatar
2 Respuestas
+ 1
Try using a boolean. You could create a boolean "initialized" that is false at first. Then in the onDataChanged() method you can check if initialized is false or not. If it is false then simply return. Next after you attach the listener to a DatabaseReference or any other thing then simply set the initialized variable to true. Hope this works.
24th Dec 2022, 7:26 AM
Rivan
+ 1
Rivan it does, thats basically what I did :)
24th Dec 2022, 7:29 AM
Yahel
Yahel - avatar