What is meant by Activity-scoped listener? And how is it different from a simple addOnCompleteListener like this!
An Activity-scoped listener is a listener for you specify an activity when you register it.
From the docs you linked:
public Task<TResult> addOnCompleteListener (Activity activity, OnCompleteListener<TResult> listener)
Adds an Activity-scoped listener that is called when the Task completes.
The listener will be called on main application thread. If the Task is already complete, a call to the listener will be immediately scheduled. If multiple listeners are added, they will be called in the order in which they were added.
The listener will be automatically removed during
onStop()
.
That last bit (emphasis mine) is crucial: when you register a listener with an activity scope, it won't be called if that activity is not active anymore. This is great for listeners that for example need to show their data in the activity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With