gpt4 book ai didi

android - android 中的 Activity-scoped listener 是什么意思?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:42:20 24 4
gpt4 key购买 nike

**A snap from the documentation of firebase**

Activity-scoped listener 是什么意思?它与像 this 这样的简单 addOnCompleteListener 有何不同? !

最佳答案

Activity-scoped listener 是您在注册 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 状态,则不会调用它。这对于需要在 Activity 中显示数据的听众来说非常有用。

关于android - android 中的 Activity-scoped listener 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37786070/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com