In my MainActivity, I have 4 fragments. When I rotated the screen, new Fragment objects will be recreated, that makes my app very slow, sometimes it generated Android not responding. Could you tell me a way to fix it?
In MainActivity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (homeFragment == null) {
homeFragment = new HomeFragment(this);
}
if (photoFragment == null) {
photoFragment = new PhotoFragment(this);
}
if (videoFragment == null) {
videoFragment = new VideoFragment(this);
}
if (settingFragment == null) {
settingFragment = new SettingFragment(this);
}
....
}