本文介绍了我的活动A,B,C中有3个片段。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的活动A,B,C中有3个片段。该流程是A-> B,B-> C,C-> B,A后退按下app退出,B后退按下app退出。我有一个自动注销功能,它采用片段C-> A但在此之后按回按钮时片段A移动到C而不是App退出。我使用下面的代码来自C-> A Fragment。我希望当我来自C-> A并按下后退按钮时应该退出应用程序。



FragmentTransaction fragmentTransaction = getActivity()。getSupportFragmentManager()。beginTransaction( );

fragmentTransaction.replace(R.id.frameLayout_main,ApplicationConstants.loginFragment);

fragmentTransaction.addToBackStack(null);

// fragmentTransaction.commit();

fragmentTransaction.commitAllowingStateLoss();

I have 3 fragments in my activity A,B,C. The flow is A->B,B->C,C->B, A Back pressed app exit,B back pressed app exit. I have an auto logout feature which took fragment C->A but after that when press back button the fragment A moves to C instead of App exit. i have used the below code to go from C->A Fragment. I want when i come from C->A and press back button the application should be exited.

FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frameLayout_main, ApplicationConstants.loginFragment);
fragmentTransaction.addToBackStack(null);
//fragmentTransaction.commit();
fragmentTransaction.commitAllowingStateLoss();

推荐答案


这篇关于我的活动A,B,C中有3个片段。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 13:13