0

My MainActivity contains 4 fragments. My home-fragment is FragmentA. When I press on back button at FragmentB,C or D, I have to return back to FragmentA. If I am on FragmentA and press back button, I have to moveTasktoBack().

What is the best way to do it?

Aras Gogce
  • 33
  • 7

2 Answers2

0

When You replacing the fragment from home fragment and form A then use like this Like

FragmentTransaction.replace(R.id.content_frame, fragment);

then after that paste this line

FragmentTransaction.addToBackStack(backStateName);

from B and C don't use

FragmentTransaction.addToBackStack(backStateName);
Shadik Khan
  • 1,217
  • 1
  • 8
  • 18
0

Check out this answer

Just change it so it returns to your home fragment. In the future try to search before you ask, more often than not the answer already exists.

Community
  • 1
  • 1
Kony2013
  • 171
  • 9