gpt4 book ai didi

android - 这个 AsyncTask 类应该是静态的,否则可能会发生泄漏

转载 作者:行者123 更新时间:2023-11-29 02:35:30 25 4
gpt4 key购买 nike

<分区>

我在一个方法中创建了asynctask。但它显示警告。

This AsyncTask class should be static or leaks might occur (anonymous android.os.AsyncTask) less.. A static field will leak contexts. Non-static inner classes have an implicit reference to their outer class. If that outer class is for example a Fragment or Activity, then this reference means that the long-running handler/loader/task will hold a reference to the activity which prevents it from getting garbage collected. Similarly, direct field references to activities and fragments from these longer running instances can cause leaks. ViewModel classes should never point to Views or non-application Contexts.

我怎样才能避免这个警告?

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