Suppose I'm in fragment A, then moving to B, then using Back button returns to A. In the activity I'm performing the following override:
@Override
public void onBackPressed(){
FragmentManager fm = getSupportFragmentManager();
Fragment frag = fm.findFragmentByTag(Consts.A);
if (frag != null){
Log.d(Consts.TAGS.ACTIVITY_ORDER,"");
fm.beginTransaction().remove(frag).commit();
fm.popBackStack();
}
}
and while showing B goes like this:
FragmentManager fm = getActivity().getSupportFragmentManager();
Fragment f = BFragment.newInstance(Consts.B);
fm.beginTransaction()
.replace(R.id.rl_content,
f,
Consts.B)
.addToBackStack(null)
.commit();
Now, which method (if any) will be executed in A, once we execute popBackStack()
?
If none, how can we change A's data models or UI components (such as keyboard or a TextView
) right after back press? is it component-dependent?
R.id.rl_content
is the container.
Please consider 2 cases:
1. A is in R.id.rl
and being replaced
2. A is not in R.id.rl
and is not being replaced