java - Fragments and android life cycle -


i've got strange android app.

if run main activity , go through few fragments, i'll see main activity after hiding/unhiding app. if press "back", show fragment shown right before hiding. app shows me last fragment after unhiding. how can make app show last fragment everytime if it's possible? or how can make app save state?

if understand, want when "back" button pressed, last fragment should displayed. can depend on addtobackstack method handle press. google code snippet @ fragments:

fragment newfragment = new examplefragment(); fragmenttransaction transaction = getfragmentmanager().begintransaction();  // replace whatever in fragment_container view fragment, // , add transaction stack transaction.replace(r.id.fragment_container, newfragment); transaction.addtobackstack(null);  // commit transaction transaction.commit(); 

note: in case newfragment last fragment.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -