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
9
votes
1 answer

How to pass id and application to a viewModel/viewModelFactory in Jetpack Compose?

I use Jetpack Compose and navigation compose and I want to pass id to this viewmodel: class RecallViewModel(private val id:Long,application: Application):AndroidViewModel(application) { ............................ } Composable function: I don't…
9
votes
4 answers

Cannot create an instance of viewmodel while using Jetpack Compose navigation

I am using navigation component for jetpack compose in my app like this: @Composable fun FoodiumNavigation() { val navController = rememberNavController() NavHost( navController = navController, startDestination =…
9
votes
1 answer

No method navigate(String) in compose-navigation

I'm trying the new jetpack library "compose-navigation". According to the docs, to navigate to a route, I should use navigate() method which takes a String. navController = rememberNavController() //…
Mahdi-Malv
  • 16,677
  • 10
  • 70
  • 117
9
votes
4 answers

The Fragment refreshes on back- Android Navigation

I am making an application using the Android Navigation component. But I ran into a very fundamental problem which can cause problems in the whole development of my application. The Scenario I have this Fragment where in onViewCreated I am observing…
8
votes
0 answers

Is SavedStateHandle in ViewModel and currentBackStackEntry the same?

I want to pass some data using savedStateHandle from activity straight to fragment's viewModel. In my activity I have: navController.addOnDestinationChangedListener { controller, _, _ -> controller.currentBackStackEntry?.savedStateHandle?.set( …
8
votes
1 answer

Prevent closing bottom sheet with background click with accompanist library

I have tried accompanist library for navigation from this article and I want to prevent bottom sheet to be closed when I click on the background of bottom sheet (the gray area) and to make it non clickable at all, how can I achieve this? This is the…
8
votes
3 answers

Is Jetpack Compose Navigation good design for navigating?

The following code are from the official sample project. There are two branches, main and end. I found the Code main and the Code end using different ways to navigate. Code main is simple and clear, and in other projects, it navigate based State…
HelloCW
  • 843
  • 22
  • 125
  • 310
8
votes
4 answers

How to remove default transitions in Jetpack Compose Navigation

I'm using the following sippet of code to navigate from a composable to another one, but it has a default fade animation. How can I remove it? I tried using an empty anim resource but it doesn't work. navHostController.navigate( …
8
votes
0 answers

Why does navigation composable call twice?

Why does navigation composable call twice? If I set a breakpoint on the Text I will get two stops when the app runs. Thank you for your answers. class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { …
Сергей
  • 176
  • 1
  • 12
8
votes
4 answers

Compose navigation - replace starting route and clear back stack

I'm using JetPack Compose with composable NavHost. I have a scenario where I need a Launch screen that connects bluetooth device so I've set it as my starting route in NavHost. After connection is done I want to enter Home screen and never get back…
8
votes
2 answers

Jetpack Compose & Navigation: Problems share ViewModel in nested graph

According to this example I implemented shared viewModels in a nested navigation graph. Setup Nested Graph: private fun NavGraphBuilder.accountGraph(navController: NavHostController) { navigation( startDestination = "main", route =…
8
votes
1 answer

How to use NavController in compose ViewModel via hilt

I am using jetpack compose with the navigation compose library to navigate from one screen to the next. Usually you would have a ViewModel that would take care of user interactions (e.g.: viewModel.addItem()). In order to fulfill the addItem command…
Moritz
  • 10,124
  • 7
  • 51
  • 61
8
votes
1 answer

How to acess NavHostController from nested composable Jetpack Compose

Assume that my application looks like this @Composable fun AppNavigation() { val navController = rememberNavController() NavHost(navController, startDestination = Route.Home.route) { /// other composes composable("Home") {…
8
votes
2 answers

Missing slide_in_right and slide_out_left animations in Android?

I'm trying to use the Jetpack Navigation component. The docs here talk about animating transitions. The example code uses the animations slide_in_right and slide_out_left and acts like they will be there by default - there is no instruction on how…
Rob N
  • 15,024
  • 17
  • 92
  • 165
8
votes
4 answers

Using global actions with multiple graphs in jetpack navigation

I created an application with a bottom navigation bar and added four different nav graphs using google's advanced navigation example After that I added a fifth graph called settings that had the settings fragment along with a global action I added…
Cruces
  • 3,029
  • 1
  • 26
  • 55