简体   繁体   English

删除Firebase java中的所有侦听器

[英]Remove all listeners in Firebase java

I know that the documentation says "// In Java, each listener must be removed explicitly.". 我知道文档说“//在Java中,必须明确删除每个侦听器。” But there is a problem. 但有一个问题。

I deploy my app - add a listener (save pointer). 我部署我的应用程序 - 添加一个监听器(保存指针)。 But when I re-deploy my app the listener is still there, but I cannot remove it because I don´t have a pointer for it. 但是当我重新部署我的应用程序时,监听器仍然存在,但我无法删除它,因为我没有指针。

So is any way how to remove all listeners? 那么如何删除所有听众呢? (without server restart) (没有服务器重启)

This still applies until now, as you cannot remove all listeners at once. 这仍然适用于现在,因为您无法一次删除所有侦听器。

To check for any updates you can see this link: https://firebase.google.com/support/release-notes/android 要查看任何更新,您可以看到以下链接: https//firebase.google.com/support/release-notes/android

Currently, you can do it inside onDestroy() 目前,您可以在onDestroy()

protected void onDestroy(){
super.onDestroy();
yourdatabasereference.removeEventListener(Listenernamehere);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM