public class ActivityReleaseMemoryUtil {
private static final ActivityReleaseMemoryUtil ourInstance = new ActivityReleaseMemoryUtil();
public static ActivityReleaseMemoryUtil getInstance() {
return ourInstance;
}
private ActivityReleaseMemoryUtil() {
}
public void setContentViewNull(Activity activity){
//一个空的FrameLayout布局
View layoutNull = LayoutInflater.from(activity).inflate(R.layout.view_null, null);
activity.setContentView(layoutNull);
if(null!=layoutNull)layoutNull = null;
}
public void clearViewGroups(ViewGroup...viewGroups){
for (ViewGroup vg :
viewGroups) {
if (null != vg){
vg.removeAllViews();
vg = null;
}
}
}
public void clearList(List...lists){
for (List list :
lists) {
if (null != list) {
list.clear();
list = null;
}
}
}
//viewpager recyclerview listview,要设置setAdapter(null);后再置为空等等等......
}
activity执行onDestroy后最大化回收内存
最新推荐文章于 2021-12-09 15:47:23 发布