get the latest fragment in backstack

后端 未结 17 2050
长发绾君心
长发绾君心 2020-11-27 11:24

How can I get the latest fragment instance added in backstack (if I do not know the fragment tag & id)?

FragmentManager fragManager = activity.getSupport         


        
17条回答
  •  独厮守ぢ
    2020-11-27 11:58

    The highest (Deepak Goel) answer didn't work well for me. Somehow the tag wasn't added properly.

    I ended up just sending the ID of the fragment through the flow (using intents) and retrieving it directly from fragment manager.

提交回复
热议问题