Questions tagged [android-jetpack-navigation]

Navigation between different screens and apps is a core part of the user experience. Android Jetpack Navigation Component helps the developer to implement it following the good practices. For more info see documentation: https://developer.android.com/guide/navigation

834 questions
8
votes
0 answers

setOnApplyWindowInsetsListener() is not applying padding and calling 2 times

I'm calling setOnApplyWindowInsetsListener to add padding/margin for my views. My XML contains android:fitsSystemWindows="true" setOnApplyWindowInsetsListener after being called 2 times (on second time there insets of 0s). Why Android returns…
8
votes
2 answers

Shared ViewModel in scope of parent fragment using Navigation Component

I am trying to use the same instance of ViewModel in Parent Fragment and its children, using Navigation Component. The hierarchy is as follows: Single Activity that has navigationHost. This host has 3 child fragments, A, B and C. The last fragment…
8
votes
1 answer

Passing data from one viewmodel to another android MVVM

I have a design-related question for you guys. So, I have been following Guide to App Architecture by Google to build my application using Kotlin, MVVM and data binding. I am using Jetpack components(navigation, livedata etc) as prescribed by…
8
votes
2 answers

Android Navigation Component fragment transitions have white background

I'm using the Jetpack Navigation library and having an issue with the fragment transitions, either if it's a fade or slide animation it always has a white background instead of the previous screen content. fragment A -> fragment B, when the…
7
votes
1 answer

Same fragment with different navgraph by hiltNavGraphViewModels

I followed single activity pattern for my app. My MainActivity has a bottom navigation with 4 fragments. nav_home and nav_video have same fragment so I want to HomeViewModel and VideoViewModel keep their states within these graphs. As you can see…
7
votes
2 answers

Compose - NavHost recomposition multiple times

During navigation from Navhost, I found out that the composable screens are getting recomposition multiple times. Because of it, my ViewModel is calling API data source multiple times too. @Composable fun MainView() { val scaffoldState =…
7
votes
2 answers

NullPointerException on FragmentHostCallback.getContext()

I'm facing this random crash while navigating to a Fragment via deep-link which is declared in the navigation graph file. I'm using navigation component library in my project. Stacktrace: Fatal Exception: java.lang.NullPointerException: Attempt to…
7
votes
2 answers

How to navigate to Detail View clicking in LazyColumn item with JetPack Compose?

I am trying to create an app with JetPack Compose (first time) and I am having some problem with the navigation. The application has a bottomBar with 3 items that navigates to the selected screen. This works, the problem is when I try to access one…
7
votes
3 answers

BottomNavigationView.setupWithNavController not working

Currently I'm developing an Android app, in which I would like to utilize both Android Navigation Component and BottomNavigationView. While working on said app I checked out the official codelab and several questions here, but they didn't prove to…
7
votes
2 answers

Jetpack compose navigation popUpTo inclusive true not cleared composable screen from backstack

I am using Jetpack Compose ui version 1.3.0-beta08 and navigation compose version 2.4.0-alpha02 and working Bloom app with all new Architecture components. After login success I need to clear all previous compose login screens, but even added…
7
votes
3 answers

Jetpack compose NavHost prevent recomposition screens

as you see this is how i implemented NavHost with MaterialBottomNavigation, i have many items on both Messages and Feeds screens, when i navigate between them both screens, they automatically recomposed but i don't wanna because of much data there…
7
votes
2 answers

Remember list item states while navigating in Jetpack Compose

If we create state for a list item like val state = remember(it) { mutableStateOf(ItemState()) } then we lose expanded state while scrolling. If we move state generation up higher before LazyColumn then expand state saves properly val states =…
7
votes
2 answers

Android navigation component passing argument with safeArgs and deep link

I have a navigation xml for a feature as below -
Ma2340
  • 647
  • 2
  • 17
  • 34
7
votes
0 answers

How to display layout in Jetpack Navigation when using Compose?

I started using Jetpack Compose and I'm very happy with it. I replaced a couple of layouts that where defined in xml by a @Composable function. When I went back to my Navigation-xml I noticed that the preview inside every screen is done with…
7
votes
2 answers

Navigate from ViewPager2 to another fragment using jetpack

I have single activity, FragmentHome contains viewpager2. Inside of viewpager there is FirstFragment. when I want to navigate from FirstFragment to SecondFragment which is not in viewpager2 it throws java.lang.IllegalArgumentException:…