I am using a ViewPager to implement swiping in my android app. However, I would like the previous fragment to be shown when the user uses the back button instead of ending t
If you are using the Jetpack Navigation component, chances are you have a single activity and are trying to manage the backstack inside a fragments.
In which case the OnBackPressedDispatcher comes handy.