I need to pre load a complex layout so I can show the activity more quickly the first time:
LayoutInflater inflater = (LayoutInflater) mainActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
SlowActivity.cachedView = inflater.inflate(R.layout.activity_layout, null, false);
when SlowActivity starts...
public static View cachedView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(this.cachedView);
}
}
I can't find where I read it but some one says that I'm doing a memory leak using a stati variable to store inflated layout.
Why?
Maybe I need to release some resource when activity is destroyed (never, it's always put on the background...)