Lucas Cavalcante
Apr 4, 2019 · 1 min read

I see… you are trying to set new destination from your fragment, that’s fine. I do not know how your Fragment’s ViewModel are being instantied, but if you want to create a communication between Activity and Fragment your ViewModel need to be instantiated like:

ViewModelProviders.of(getActivity(), factory).get(MyViewModel::class.java)

Then this way your fragment will use its activity’s viewmodel instance instead of its own.

I do not see your Fragment’s ViewModel implementation, but I think it can be the problem, because you are trying to change the destination from the Fragment and observing state changes in your activity.

Lucas Cavalcante

Written by

Love Android and all others things.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade