I made an Android app which receives realtime data from Firebase database. In my main Activity the user has to log in with e-mail and password and by success it opens a new Activity, which receives data.
It seems to be, that when the user leaves my app, the Firebase connection is still established. That is not good for the battery.
How is the way to manage the connection for closing and reopen the app? I think I need to use
Yes, you may use the activity lifecycle methods like
onDestroy() to close your connection.
Also, it seems Firebase still has a
goOffline() method - https://www.firebase.com/docs/android/api/#firebase_goOffline.