Reputation: 707
i am using
navController.navigate(R.id.FragmentB)
to navigate from host fragment in MainActivity to navigate to different fragments and it works like expected except inside onActivityResult it won't respond ,i am returning an ID from other activity and want to navigate to Fragments depending on that ID but it is not responding ,
Upvotes: 5
Views: 841
Reputation: 2733
If you're not using coroutines, a simple Handler()
will do the trick.
Handler().post {
navigate()
}
Upvotes: 4
Reputation: 707
It turns out that i needed to create a Coroutine and run my navigation function on it , i tried with :
GlobalScope.launch(Dispatchers.Main) {
navigate()
}
and it works fine, obviously gotta need to optimise my coroutine ,but that was the main issue
Upvotes: 2