I just having a certain problem about the Firestore snapshot listener. I am new on using it and I had read that you have to stop the snapshot listener everytime you move to another activity. I tried:
db.collection("Mydata").document(userID).addSnapshotListener(itemView.getContext(), new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
}
})
But it has an error because of the itemView.getContext()
.
My questions are:
- Is it okay if I don't include the
Activity
in and leave the snapshotlistener like that? - If not, Is there any way to solve this?