android - Fragment not readded on restart -


i have activity manages 4 fragments. activity decides when add/replace/hide/show fragments. when application closed (due low memory) , reopened user, fragments not automatically readded fragment manager. how can save fragments added when application restarted user brought same page on previously?

i assume use onsaveinstancestate() i'm not sure save...

thanks

one thing keeping track of displayed screen integer. activity hold private int current screen value.

private int currentscreen = -1; private static final int screen_menu = 0; private static final int screen_profile = 1; private static final int screen_help = 2;  private void switchtomenu(){     currentscreen = screen_menu;     //load fragment frame. }  private void switchtoprofile(){     currentscreen = screen_profile;     //load fragment frame. }  private void switchtohelp(){     currentscreen = screen_help;     //load fragment frame. }  @override public void onresume(){     switch(currentscreen){     case screen_menu: switchtomenu(); break;     case screen_profile: switchtoprofile(); break;     case screen_help: switchtohelp(); break;     } } 

this method won't save on screen want track current page being displayed hence care currentscreen. should idea anyway.

:)


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -