I have done enough research and cannot find the answer I need.
What I know:. When I bind a ValueEventListener to a database link, I know that I need to delete it later (finding it difficult now with some massive memory leak.
What I DO NOT Know: Do I also need to disconnect all other listeners? (This includes Firebase Database, Storage, and Auth, the three APIs I use)
Example:
UploadTask uploadTask = ref.putFile(uploadFile); uploadTask.addOnFailureListener(new OnFailureListener() { //@Override code here }).addOnSuccessListener(new OnSuccessListener<UploadTask.TakeSnapshot>() { //@Override code here }).addOnProgressListner(new OnProgressListner<UploadTask.TakeSnapshot>() { //@Override code here };
I think this is enough to show you the meaning of what I mean. This is how my actual code is currently structured.
Questions:
- Do I need to remove all of these listeners just in case? (system solution, the phone dies, whatever) before this callback occurs?
- Is it possible to somehow connect them and finish them all three times because I have 30 of them in my code and really donβt feel like restructuring all this to assign all these listeners to JUST variables, so I can pass them to " removeBlahBlahBlahListener (listenerVariable) "over and over.
- A little off topic, but I'm too lazy to move all my code from onCreate to onStart ... it's bad practice for me to remove all these listeners, finish work, end call () (or whatever it kills activity, although I think this is not guaranteed) and just recreate activity from scratch? This is a small, simple application, so the overhead of recreating activity is not a biggie. Just curious what is "right."
I suppose this is the result of poor planning and lack of knowledge (I only program for fun, not for work, unfortunately), so if I need to go a hard route, I think it's a learning experience, right?
source share