在android活动中,我们用来清理顶级活动intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
如何实现这个片段
答案 0 :(得分:2)
使用此:
private void clearBackStack() {
FragmentManager manager = getSupportFragmentManager();
if (manager.getBackStackEntryCount() > 0) {
FragmentManager.BackStackEntry first = manager
.getBackStackEntryAt(0);
manager.popBackStack(first.getId(),
FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
}
答案 1 :(得分:1)
FragmentManager fm = getActivity().getSupportFragmentManager();
for(int i = 0; i < fm.getBackStackEntryCount(); ++i) {
fm.popBackStack();
}