Hello.
I recently discovered that ValueEventListener , tied to Firebase , continued to work even after calling StartActivity in it and then finish() . It became noticeable, because inside there was a call for a new Activity and after each change in the database, that method was called.
It turns out that all Listener'ы that I created in Activity work all the time until the program process is completely turned off, but they do not manifest themselves explicitly, since just update the ArrayList'ы in the background. In this regard, a reasonable question arose: is it necessary to completely kill an Activity when calling a new one? On enSO I read that it is enough to call return after finish() , but this is not always possible. In my case, I simply called the removeEventListener() method removeEventListener() DatabaseReference object after calling the new Activity .
Based on these reflections, I came to the conclusion that you need to delete the EventListener every time you switch to a new Activity . But how does the transition to the previous Activity by pressing the "back" button? Will the onCreate method be called again in that Activity ? If not, then the Listener will not be reinstalled.
In short, help resolve my dilemma. Thank you in advance for your response.
onPause()is called when a newActivitycalled over the current one. Is it called whenfinish()called? Or do you need to separately registeronStop()? And do I need to transfer the initialization of components fromonCreatetoonResumeor only to reinstall theListenerinonResume? - ahgpoug