Sreekanth Karumanaghat
Sreekanth Karumanaghat

Reputation: 3403

Firebase Base listener behaviour

Will the addListenerForSingleValueEvent be fired even after the parent activity that hosts the listRef has been destroyed?

 DatabaseReference listRef = FirebaseDatabase.getInstance().getReference(Constants.Client + "/"+Constants.branch);
            listRef.keepSynced(true);
            listRef.addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {



                }

                @Override
                public void onCancelled(DatabaseError databaseError) {

                }
            });

Upvotes: 0

Views: 85

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 600126

Firebase Database listeners are not associated with an activity or other context. If you don't want them to fire after the activity has been destroyed, you should remove the listener in the correct lifecycle method of your activity.

Also see:

Upvotes: 1

Related Questions