android 中的 Activity-scoped 侦听器是什么意思?

What is meant by Activity-scoped listener in android?

Activity-scoped听众是什么意思?它与像 this!

这样的简单 addOnCompleteListener 有何不同

Activity-scoped 监听器是您在注册时指定activity的监听器。

来自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().

最后一点(强调我的)很重要:当您使用 activity 范围注册侦听器时,如果 activity 不再处于活动状态,则不会调用它。这对于需要在 activity.

中显示数据的听众来说非常有用