Status Update
Comments
pa...@google.com <pa...@google.com> #2
Can you attach a sample project that reproduces your issue?
ti...@google.com <ti...@google.com> #3
I'm experiencing this issue in a commercial non-open source project so I'd have to provide extracted code fragments. The menu file for instance looks similar to this:
<menu>
<item
android:id="@+id/destination_one" />
<item
android:id="@+id/destination_two" />
<item
android:id="@+id/destination_three" />
<item
android:id="@+id/destination_four" />
</menu>
The menu item ids match the top level destination ids as for instance destination_one as required by the NavigationUI library.
The xml layout file of the main activity (there is only one activity) looks pretty much like this:
<androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.constraintlayout.widget.ConstraintLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/navigation_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/main_navigation" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/navigation_host_fragment"
app:menu="@menu/main_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
The main_navigation
is the first navigation graph I posted in the original post. The behavior I described above only affects the first bottomNavigation item which corresponds to the top level navGraph's startDestination.
ti...@google.com <ti...@google.com> #4
Yeah, what we're looking for is a full project (i.e., take a brand new project in Android Studio, put your few bits of code in, and make sure your problem reproduces) as there are a lot of little pieces that can make a difference here.
yu...@gmail.com <yu...@gmail.com> #5
Of course the logic of my project is more sophisticated but this reproduces the issue quite well. If you click the first BottomNavigation item N times you need N+1 system back navigation triggers to leave the app.
pr...@gmail.com <pr...@gmail.com> #6
pr...@gmail.com <pr...@gmail.com> #7
Thanks a lot for your help! I basically removed the first embedded graph by moving the code directly into the topmost navGraph and as you said, navigate directly to the start destination. As far as I can tell, it seems to work now.
ey...@gmail.com <ey...@gmail.com> #8
Branch: androidx-main
commit 5624b7cefcfe5e0abb01f1063b040e5f2f135b75
Author: Clara Fok <clarafok@google.com>
Date: Wed Nov 30 16:47:38 2022
Clean up launchSingleTop logic
Basic refactoring in preparation for fix to
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 253256629
Change-Id: Ib65764c345451d8be4613f6e3d278cc1a170091e
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
an...@gmail.com <an...@gmail.com> #9
jo...@veeva.com <jo...@veeva.com> #10
This has been fixed internally and will be available in Navigation 2.6.0-alpha05
Description
I had to revert the following CL:https://android-review.googlesource.com/c/platform/frameworks/support/+/1660322
Because it was failin in runtime on:
Full failure here:https://android-build.googleplex.com/builds/tests/view?invocationId=I12700008312692285&redirect=https%3A%2F%2Fsponge2.corp.google.com%2Fe6448de7-98c2-4e78-a3c0-e5b68350d9ac&testResultId=TR67920332007834860
To fix that I changed this interface:https://android-review.googlesource.com/c/platform/frameworks/support/+/1660322/2/compose/test-utils/src/commonMain/kotlin/androidx/compose/testutils/ComposeTestCase.kt
Into a class like this:https://android-review.googlesource.com/c/platform/frameworks/support/+/1675456/1/compose/test-utils/src/commonMain/kotlin/androidx/compose/testutils/ComposeTestCase.kt