https://kotlinlang.org logo
Title
i

iex

04/21/2020, 7:50 AM
can I find a fragment in the backstack with its id? This:
private fun NavHostFragment.hasDestinationInBackstack(destinationId: Int): Boolean {
    for (index in 0 until childFragmentManager.backStackEntryCount) {
        if (childFragmentManager.getBackStackEntryAt(index).id == destinationId) {
            return true
        }
    }
    return false
}
doesn't work, because
id
returns 0, 1, 2... with tag maybe?
a

adeyds

04/21/2020, 10:56 AM
findNavController(R.id.host_fragment)
        .currentDestination?.id == R.id.targetFragment
i

iex

04/22/2020, 9:23 AM
"backstack" 🙂