I have a number of fragments which have been added (not replaced) one on top of the other. And they have also been added to the back stack expect the first one.
Fragment A -> Fragment B -> Fragment C
Hardware Back Btn press works fine when I am on Fragment B and thus come back to Fragment A. But on Fragment C when i do Hardware Back Btn press, the FIRST time nothing happens and I just get the following log:
W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
After that on the second attempt at Hardware back Btn press, onBackPressed() is called in the activity and Fragment C is popped and Fragment B is visible.
I do have a number of Edit Text wrapper in TextInputLayout on Fragment C but not sure how they could be leading to this behaviour, if at all.
Could someone please help me figure why on first time Hardware back Btn press in Fragment C onBackPressed() is not called and just the above warning?
Thanks
private void navigateToFragment(@NonNull Fragment fragment, boolean addToBackStack, int enterAnim, int exitAnim, int popEnterAnim, int popExitAnim) {
FragmentManager fragmentManager = getSupportFragmentManager();
final FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAnim);
transaction.add(R.id.member_address_root, fragment, fragment.getClass().getSimpleName());
if (addToBackStack){
transaction.addToBackStack(fragment.getTag());
}
transaction.commit();
}