简体   繁体   English

何时释放android资源?

[英]When the android resources are freed?

I declare a private variable in the fragment HomeFragment.java, 我在片段HomeFragment.java中声明了一个私有变量,

private List&ltWeatherCard> mWeatherCards = new ArrayList<>();
public class WeatherCard {
    private String city;
    private TextView mWeatherIcon;
    private TextView mCityText;
    private TextView mTemperatureText;
    private TextView mRefreshTimeText;
    private TextView mDescription;
    private TextView mWindIcon;
    private CardView mCardView;
}

When I press the back button on the android navigation bar, application is closed and activity had called the onDestory() method, but I found the variable mWeatherCards is not being recycled, and that being cleaned only when I use taskmanager to close the app. 当我按下android导航栏上的后退按钮时,应用程序关闭并且活动调用了onDestory()方法,但是我发现变量mWeatherCards没有被回收,并且仅当我使用taskmanager关闭该应用程序时才被清理。 What is the difference close app between the taskmanager and back button and When the android resources are freed? 关闭任务管理器和后退按钮以及释放Android资源之间的关闭应用程序有什么区别?

Application doesn't quit when you press back button, its moved to background and resources are still on hold. 当您按下返回按钮时,应用程序不会退出,它已移至后台并且资源仍处于保留状态。 If you want to quit your application on back button, you can follow this link Android: Quit application when press back button 如果要退出后退按钮,可以单击以下链接Android:按下后退按钮退出应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM