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

python - Overwriting the save method of a Django model -

java - how to browse all messages from 2 different MQQueue in the same function? -

How to run C# code using mono without Xamarin in Android? -