Navigation Component for Android Part 2: Graphs and Deep Links | raywenderlich.com

In this tutorial you’ll use the Jetpack Navigation component to write an Android app utilizing graphs and deep links to navigate through different screens.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4332831-navigation-component-for-android-part-2-graphs-and-deep-links

Thank a lot for the tutorial. everything was going great when I user viewModel in graph scope. But the problem began when I tried to user LiveData to assign Value of header layout’s textView and Image View. I call a api from my host activity to retrieve value of User Info which is written in shared ViewModel. When I call that ViewModel from my host activity, it said “No NavGraph with ID 2131362500 is on the NavController’s back stack”. That’s why viewMOdel isn’t initialized. So Api call is not triggered.

Finally, I have solved the problem. Cause I gave wrong parameter in initializing viewModelProvider. I used navigation_fragment instead of navigation_graph. That’s why i was in trouble. Now Problem Solved

@a_omee Really glad you sorted it out! Cheers! :]

I believe, this line
2. sendLocalNotification : Builds a notification from the letter object.

should be like
2. buildLetterNotification : Builds a notification from the letter object.

@taingmeng Can you please help with this when you get a chance? Thank you - much appreciated! :]

@taingmeng @shogunkaramazov

how do you set launch mode of fragment when creating deeplink with pending intent ?

 val contentPendingIntent =
    NavDeepLinkBuilder(applicationContext).setComponentName(HostActivity::class.java)
      .setGraph(R.navigation.nav_graph)
      .setDestination(R.id.tasksFragment)
      .createPendingIntent()

i want this to be single top or else multiple fragments are pushed i am in the app and clicked on notification