Maurice
Maurice

Reputation: 81

How to finish a fragment using kotlin

I tried things like activity?.finsish but it closed the complete app. This is where I want to finish the frgament:

lifecycleScope.launch {
        delay(2000)
        findNavController().navigate(R.id.action_splashFragment_to_authenticationFragment)
       // Here I want to finish my Fragment
    }

Is there another solution? Thank you in advance

Upvotes: 0

Views: 465

Answers (1)

val navOptions = NavOptions.Builder().setPopUpTo(R.id.splashFragment, true).build()
findNavController().navigate(R.id.action_splashFragment_to_authenticationFragment, null, navOptions)

Upvotes: 2

Related Questions