'Fragment backstack with NavDeeplinkbuilder usgin Navigation components

I have single activity app using navigation components. I have three fragments: WelcomeScreen -> HomeScreen -> MovieDetailsScreen. I use Notification in my app and when I click notification, it navigates me to MovieDetailsScreen but when I press back arrow, it navigats me to WelcomeScreen. I do not want this behavor. When I pres back arrow, I want me to navigate to HomeScreen and when I press back arrow again, I want the app to be closed. How to delete the WelcomeScreen from backstack?

val pendingIntent = NavDeepLinkBuilder(context)
              .setGraph(R.navigation.mobile_navigation)
              .setDestination(R.id.MovieDetailsScreen)
              .setArguments(bundle)
              .createPendingIntent()

          NotificationCompat.Builder(context, CHANNEL_ID)
              ....
          .setContentIntent(pendingIntent)
              .build()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source