Differentate between first time querysnapshot and change listener in firestore
Take a careful look at the code in the docs you referenced. It's checking the Type of each DocumentChange object in the QuerySnapshot object:
for (DocumentChange dc : snapshots.getDocumentChanges()) {
switch (dc.getType()) {
case ADDED:
Log.d(TAG, "New city: " + dc.getDocument().getData());
break;
case MODIFIED:
Log.d(TAG, "Modified city: " + dc.getDocument().getData());
break;
case REMOVED:
Log.d(TAG, "Removed city: " + dc.getDocument().getData());
break;
}
}
This goes along with the text you cited:
The first query snapshot contains added events for all existing documents that match the query.
You can tell if you've seen a document for the first time because it's an ADDED type of change. MODIFIED and REMOVED type changes are only issued for documents you've seen previously for this listener.