-1

I am currently working on sample android navigation drawer application. It contains 1 activity and four fragments (import android.app.Fragment). I do not know how to resume the previous fragments, for example now I am in Fragment A here I did some activities like selected checkbox some thing like this. then I have moved to Fragment B, now if I press back button I want to resume the Fragment A with the previous state (with selected check box). please provide some sample code.

thanks in advance

1 Answers1

0

As described in the documentation (http://developer.android.com/training/implementing-navigation/temporal.html#back-fragments) you can add the fragment to the back stack:

getSupportFragmentManager().beginTransaction()
                       .add(detailFragment, "detail")
                       // Add this transaction to the back stack
                       .addToBackStack()
                       .commit();
JasonOfEarth
  • 739
  • 7
  • 10
  • I can not use getSupportFragmentManager(), instead of that I am using getFragmentManager() is it cause any isuues. if not then please explain how to get the fragment from backstack, I have added the fragment to backstack but struggling to get from backstack – Prabaharan Rajendran Feb 25 '15 at 08:04
  • Using getFragmentManager is fine, it just means you're not using the support library so your stuff isn't backwards compatible. You shouldn't get it from the backstack when you use the back button it pulls from the top of the back stack which should include your fragment. – JasonOfEarth Feb 25 '15 at 08:09