How can I navigate from an activity to another using Navigation Component and removing the first activity from the stack?

天涯浪子 提交于 2019-12-11 04:13:26

问题


In my app I have two activities (AuthenticationActivity and MainActivity), each one with a nav graph and a big flow of fragments. I've created an action to navigate from a fragment of the AuthenticationActivity's graph to the MainActivity but it does not remove the AuthenticationActivity from the stack even if I set 'popTo' to the Authentication graph id.


回答1:


finish authentication activity after navigate method:

button2.setOnClickListener {
        view.findNavController().navigate(R.id.action_addItemFragment_to_mainActivity)
        (activity as AuthenticationActivity).finish()
    }


来源:https://stackoverflow.com/questions/54824838/how-can-i-navigate-from-an-activity-to-another-using-navigation-component-and-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!