You need to use addListenerForSingleValueEvent
instead of addValueEventListener
.
addValueEventListener
- which goes on listing events continuously.
addListenerForSingleValueEvent
- listens for the very
first event only.
In your code, just replaceaddValueEventListener
with addListenerForSingleValueEvent
, that's all, leave the reamaining portion of the code intact.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…