Handling Back stack Navigation in Compose

338 Views Asked by At

I have a question regarding compose navigation. I have Activity A which is child to other activity. Activity A has a composable view to set to the content.

Now from A have to navigate to a fragment B for which i use Navhost and add a composable with a route for it to navigate and it does that successfully.

but now the problem is that when i press back from Fragment B it goes to the parent of Activity A.

Any idea what can be done about it

CODE :

 NavHost(
        modifier = Modifier.semantics { testTagsAsResourceId = true },
        navController = navController,
        startDestination = startDestination ?: route.value
    ) {

 composable(route.value) {
            FragmentContainer(
                modifier = Modifier.fillMaxSize(),
                fragmentManager = activity.supportFragmentManager,
                commit = {
                    add(it, SomeFragment().apply {
                        arguments = Bundle().apply {
                            putString(AppConstants.EXTRA_MODEL.value)
                        }
                    })
                }
            )
        }
}```
0

There are 0 best solutions below