5

I got activity a. then I put b in backsatck and display it;
I want to call c such that a not called again however I want to pop B from BackStack such that return back from C I want it returns to A.
Here is the scenario:
A->B
C Called: A->C
C closed onback pressed: return back to A
However When I pop B from backstack (in order to replace it with C) fragment A onResume called and do not allow B to be displayed normally. I also used:

fragmentManager.popBackStack(null,FragmentManager.POP_BACK_STACK_INCLUSIVE);`

However this does not fix the problem. Here is code for switchFragments:

fragmentManager.popBackStack(null,
                FragmentManager.POP_BACK_STACK_INCLUSIVE);

        if (fragment != null) {
            FragmentTransaction transaction = fragmentManager
                    .beginTransaction();
            transaction.replace(R.id.content_frame, fragment, tag);
            // Only ArticlDetailFragment is added to the back stack.
            if (!(fragment instanceof HomeFragment)
            /* && isItNotification == false */) {
                if (debug == 1)
                    Log.v("DEBUG_TAG", "MainAcitivy switchContent2");

                transaction.addToBackStack(tag);
            }
            transaction.commit();
            contentFragment = fragment;
        }

HomeFragment is what is called A here.

VSB
  • 9,825
  • 16
  • 72
  • 145

1 Answers1

-1

Instead of replacing fragment add them in the backstack :

getFragmentManager().beginTransaction().add(R.id.content_frame, fragment).addToBackStack(null).commit();
WilQu
  • 7,131
  • 6
  • 30
  • 38
Harsh Parikh
  • 3,845
  • 3
  • 14
  • 14
  • what does this addToBackStack(null) does? I mean what is differce with addToBackStack(TAG)? – VSB Oct 15 '14 at 13:50