Fixed
Status Update
Comments
cl...@google.com <cl...@google.com>
pa...@gmail.com <pa...@gmail.com> #2
Hi Ed, Thank you so much for these suggestions. I've been reviewing them and merging them in. Hopefully it should be live. I've included a thank you note too in the article.
ap...@google.com <ap...@google.com> #3
Great! Thanks a lot, I'll look for the live updates soon!
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be part of the Navigation 2.3.5
release (via 2.4.0-alpha01
).
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-main
commit f231e0f384f9fd2e7a078bfcbeb7768c82c617b1
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 17 17:40:05 2021
Add BackHandler callback with a LifecycleOwner
We need to ensure that the callback from BackHandler remains in the
proper position in the event of Lifecycle changes.
RelNote: "The BackHandler will now properly intercept back presses in
the event that the Activity is STOPPED, then STARTED again, and other
callbacks were added with a LifecycleOwner."
Test: BackHandlerTest
Bug: 182284739
Change-Id: I71de6184ba73f56b34de9dcddaf138d98c46417f
M activity/activity-compose/build.gradle
M activity/activity-compose/src/androidTest/java/androidx/activity/compose/BackHandlerTest.kt
M activity/activity-compose/src/main/java/androidx/activity/compose/BackHandler.kt
https://android-review.googlesource.com/1644062
Branch: androidx-main
commit f231e0f384f9fd2e7a078bfcbeb7768c82c617b1
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 17 17:40:05 2021
Add BackHandler callback with a LifecycleOwner
We need to ensure that the callback from BackHandler remains in the
proper position in the event of Lifecycle changes.
RelNote: "The BackHandler will now properly intercept back presses in
the event that the Activity is STOPPED, then STARTED again, and other
callbacks were added with a LifecycleOwner."
Test: BackHandlerTest
Bug: 182284739
Change-Id: I71de6184ba73f56b34de9dcddaf138d98c46417f
M activity/activity-compose/build.gradle
M activity/activity-compose/src/androidTest/java/androidx/activity/compose/BackHandlerTest.kt
M activity/activity-compose/src/main/java/androidx/activity/compose/BackHandler.kt
jb...@google.com <jb...@google.com> #6
This has been addressed internally and will be available when using both the Activity 1.3.0-alpha06
and Navigation 2.3.5
releases.
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-main
commit d1d6f89ba90be8e7fba193570b427f52ec98f57a
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 31 09:40:42 2021
Make nav compose depend on Navigation 2.3.5
Upgrading to the latest Navigation version to take advantage of fixed
bugs, (particularly around OnBackPressedDispatcher and lifecycles
b/182284739 ).
RelNote: "Navigation-compose now depends on Navigation version `2.3.5`"
Test: ./gradlew bOS
Change-Id: I7e63b32c93deaee60b1d5e132d3fa255c3ba85e2
M navigation/navigation-compose/build.gradle
https://android-review.googlesource.com/1660640
Branch: androidx-main
commit d1d6f89ba90be8e7fba193570b427f52ec98f57a
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Mar 31 09:40:42 2021
Make nav compose depend on Navigation 2.3.5
Upgrading to the latest Navigation version to take advantage of fixed
bugs, (particularly around OnBackPressedDispatcher and lifecycles
RelNote: "Navigation-compose now depends on Navigation version `2.3.5`"
Test: ./gradlew bOS
Change-Id: I7e63b32c93deaee60b1d5e132d3fa255c3ba85e2
M navigation/navigation-compose/build.gradle
mc...@gmail.com <mc...@gmail.com> #8
does not work for me on '2.4.2'
val navController: NavHostController = rememberNavController()
HomeNavHost(navController = navController)
BackHandler(true) {
// code doesnt get called here
}
val navController: NavHostController = rememberNavController()
HomeNavHost(navController = navController)
BackHandler(true) {
// code doesnt get called here
}
ri...@gmail.com <ri...@gmail.com> #9
I got similar issue, after I run launcher (exp: select document), BackHandler no longer triggers
BackHandler{
action.onBack()
}
BackHandler{
action.onBack()
}
ri...@gmail.com <ri...@gmail.com> #10
to solve BackHandler no longer triggers after i run launcher, i am using this
@Composable
fun BaseBackHandler(onBackHandler: () -> Unit = {}) {
var refreshBackHandler by rememberSaveable { mutableStateOf(false) }
OnLifecycleEvent { _, event ->
when (event) {
Lifecycle.Event.ON_PAUSE -> {
refreshBackHandler = false
}
Lifecycle.Event.ON_RESUME -> {
refreshBackHandler = true
}
else -> {}
}
}
if (refreshBackHandler) {
BackHandler {
onBackHandler()
}
}
}
@Composable
fun BaseBackHandler(onBackHandler: () -> Unit = {}) {
var refreshBackHandler by rememberSaveable { mutableStateOf(false) }
OnLifecycleEvent { _, event ->
when (event) {
Lifecycle.Event.ON_PAUSE -> {
refreshBackHandler = false
}
Lifecycle.Event.ON_RESUME -> {
refreshBackHandler = true
}
else -> {}
}
}
if (refreshBackHandler) {
BackHandler {
onBackHandler()
}
}
}
sb...@doximity.com <sb...@doximity.com> #11
Is there a way to re-open this issue? Still experiencing this on latest version of the navigation library.
il...@google.com <il...@google.com> #12
Re
[Deleted User] <[Deleted User]> #13
I opened a new bug as requested by
Description
Jetpack Compose release version: 1.0.0-beta01
Android Studio Build: #AI-203.7148.57.2031.7185775, built on March 5, 2021
Steps to Reproduce:
Code to reproduce the issue (from attached sample project):