gpt4 book ai didi

android - AsynctaskLoader 重置状态

转载 作者:太空宇宙 更新时间:2023-11-03 12:33:06 25 4
gpt4 key购买 nike

这似乎是一个愚蠢的问题,但我无法理解 AsynctaskLoader 的状态。

我已经多次阅读文档以及网络上的其他教程。但是,我仍然无法理解Asynctask 何时处于Reset 状态

看看从官方文档中提取的这段代码。 http://developer.android.com/reference/android/content/AsyncTaskLoader.html

@Override public void deliverResult(List<AppEntry> apps) {
if (isReset()) {
// An async query came in while the loader is stopped. We
// don't need the result.
if (apps != null) {
onReleaseResources(apps);
}
}

调用此方法后加载器完成其工作并需要将数据发送回 UI 线程。我的问题是:为什么我们要询问 Loader 是否已重置?。重置它甚至意味着什么?类说

/**
* Return whether this load has been reset. That is, either the loader
* has not yet been started for the first time, or its {@link #reset()}
* has been called.
*/

你会想,如果加载程序不是第一次启动,它就会处于 STOPPED 状态,为什么要重新启动?。

我想我并没有真正理解 Loader 如何对 Activity Lifecycle 使用react,但文档对此只字未提。

最佳答案

I think this will help you

我想这会对你有所帮助。这张图同时显示了 android 生命周期和 loader 生命周期。

关于android - AsynctaskLoader 重置状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27572812/

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