首页 > 技术文章 > 全局变量的回收

yangc248 2016-08-25 17:29 原文

public class xxx{

  public static  UserBean User;}

内存不足会回收闲置资源,全局变量很容易被回收。

解决方法:

不使用全局变量,使用intent来传递数值。

即便目标activity被销毁,intent还在。Oncreate被重新执行,intent值再次取得。

 

推荐阅读