Fixed
Status Update
Comments
jo...@linkedin.com <jo...@linkedin.com> #2
You don't need to do step 1 or 2 - ensuring you've called addNavigator() before setGraph() is enough.
Specifically, seehttps://issuetracker.google.com/issues/110763345#comment2
Also mentioned is the fact that you can override createFragmentNavigator(), call navController.navigatorProvider.addNavigator() there, then return super.createFragmentNavigator().
Specifically, see
Also mentioned is the fact that you can override createFragmentNavigator(), call navController.navigatorProvider.addNavigator() there, then return super.createFragmentNavigator().
il...@google.com <il...@google.com> #3
It's may also be of interest that I am making use of a custom navigator to implement conditional routing. My custom destination/nodes simply implement an interface like this:
interface DynamicNode {
@IdRes
fun getDestination(context: Context, @IdRes destinationIn: Int, argsIn: Bundle?) : Int
}
The Navigator then implements a navigate method that simply calls NavController.navigate using the ID returned by the DynamicNode and returns null, essentially performing a redirect. It would be cool to see something like this baked-in with a later version of the Navigation component.
interface DynamicNode {
@IdRes
fun getDestination(context: Context, @IdRes destinationIn: Int, argsIn: Bundle?) : Int
}
The Navigator then implements a navigate method that simply calls NavController.navigate using the ID returned by the DynamicNode and returns null, essentially performing a redirect. It would be cool to see something like this baked-in with a later version of the Navigation component.
jo...@linkedin.com <jo...@linkedin.com> #4
>> You don't need to do step 1 or 2 - ensuring you've called addNavigator() before setGraph() is enough.
Ah gotcha. Okay that's a nicer then. Thanks!
Ah gotcha. Okay that's a nicer then. Thanks!
il...@google.com <il...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 238c09170a34e1c94af42bc3c6e9fce551883aef
Author: Ian Lake <ilake@google.com>
Date: Mon Apr 22 12:54:51 2019
Rename createFragmentNavigator()
Fix confusion around what method should
be overriden to add custom Navigators to
a NavHostFragment.
Test: tested in testapp
Fixes: 122802849
Change-Id: I969dca429a62e0533cb4ca93c77e68e062278a6f
M navigation/fragment/api/2.1.0-alpha03.txt
M navigation/fragment/api/current.txt
M navigation/fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java
https://android-review.googlesource.com/947645
https://goto.google.com/android-sha1/238c09170a34e1c94af42bc3c6e9fce551883aef
Branch: androidx-master-dev
commit 238c09170a34e1c94af42bc3c6e9fce551883aef
Author: Ian Lake <ilake@google.com>
Date: Mon Apr 22 12:54:51 2019
Rename createFragmentNavigator()
Fix confusion around what method should
be overriden to add custom Navigators to
a NavHostFragment.
Test: tested in testapp
Fixes: 122802849
Change-Id: I969dca429a62e0533cb4ca93c77e68e062278a6f
M navigation/fragment/api/2.1.0-alpha03.txt
M navigation/fragment/api/current.txt
M navigation/fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java
jb...@google.com <jb...@google.com> #6
We've decided to rename createFragmentNavigator() to onCreateNavController(NavController) to make it more clear that this is something you can override to get a callback for when the NavController is created.
This will be available in Navigation 2.1.0-alpha03
This will be available in Navigation 2.1.0-alpha03
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit e3b742c6b338c04f6be0e6560c39c878376ad3ca
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Jul 16 16:22:09 2021
Mark destination navigating away from as transitioning
When navigating forward with transitions, although we don't hold the
lifecycle of the entry being kept on the back stack above CREATED during
the transition, we should still mark it as transitioning until its
transition is actually complete.
RelNote: "When navigating away from a `NavBackStackEntry` and using the
`pushWithTransition` API, the `NavigatorState` will now properly mark
the previous entry as transitioning."
Test: modified test
Bug: 172112072
Bug: 194301889
Fixes: 191870023
Change-Id: If0543dd1c20e7338078115e98b5585623f9b8f1c
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/main/java/androidx/navigation/NavigatorState.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/ComposeNavigator.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
M navigation/navigation-testing/src/androidTest/java/androidx/navigation/testing/TestNavigatorStateTest.kt
M navigation/navigation-testing/src/main/java/androidx/navigation/testing/TestNavigatorState.kt
M testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigator.kt
https://android-review.googlesource.com/1770665
Branch: androidx-main
commit e3b742c6b338c04f6be0e6560c39c878376ad3ca
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Jul 16 16:22:09 2021
Mark destination navigating away from as transitioning
When navigating forward with transitions, although we don't hold the
lifecycle of the entry being kept on the back stack above CREATED during
the transition, we should still mark it as transitioning until its
transition is actually complete.
RelNote: "When navigating away from a `NavBackStackEntry` and using the
`pushWithTransition` API, the `NavigatorState` will now properly mark
the previous entry as transitioning."
Test: modified test
Bug: 172112072
Bug: 194301889
Fixes: 191870023
Change-Id: If0543dd1c20e7338078115e98b5585623f9b8f1c
M navigation/navigation-common/api/current.txt
M navigation/navigation-common/api/public_plus_experimental_current.txt
M navigation/navigation-common/api/restricted_current.txt
M navigation/navigation-common/src/main/java/androidx/navigation/NavigatorState.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/ComposeNavigator.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavBackStackEntryTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
M navigation/navigation-testing/src/androidTest/java/androidx/navigation/testing/TestNavigatorStateTest.kt
M navigation/navigation-testing/src/main/java/androidx/navigation/testing/TestNavigatorState.kt
M testutils/testutils-navigation/src/main/java/androidx/testutils/TestNavigator.kt
di...@gal-digital.de <di...@gal-digital.de> #8
+1
jb...@google.com <jb...@google.com> #9
This has been fixed internally and will be available as part of the Navigation 2.4.0-alpha06
release.
je...@gmail.com <je...@gmail.com> #10
Phew 😅
di...@gal-digital.de <di...@gal-digital.de> #11
fix from `2.4.0.-alpha06` works
Description
Component used: Navigation Compose
Version used: 2.4.0-alpha05
Devices/Android versions reproduced on: Pixel 5, SDK 31
I have an
Activity
which displays a screen with a button (ComposableA
) and when I tap on the button, I want to display another screen (ComposableB
). When I tap back onComposableB
, I don't want to go back to theComposableA
, instead I want to close the app.My understanding was that I could do it like this:
When I tap the button,
ComposableB
appears for a brief moment, but then the app crashes with the following stack trace (see below). When I remove theinclusive = true
(or when I set it tofalse
) the app doesn't crash, but then tapping the phone's back button takes me back toComposableA
. I don't want – I want the app to close when I tap back. Think ofComposableA
as just a login screen.I can't figure out what am I doing wrong. I was following this documentation . I feel like this could be a bug in Navigation or Compose.
These are my build.gradle files, if that helps: