Assigned
Status Update
Comments
fi...@gmail.com <fi...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 85c1de7395f07e3256a50706d4f619e654624250
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 19 13:54:21 2019
Ensure Fragment OnBackPressedCallbacks take priority
As FragmentController is not yet driven by a
LifecycleObserver ( b/127528777 ), LifecycleObservers on
Fragments are not necessarily nested within
LifecycleObservers registered at the Activity level.
This can lead to cases where a Fragment is started
before the Activity's Lifecycle is started.
In the case of FragmentManager's usage of Lifecycle to
add OnBackPressedCallbacks, that nesting is critical
to ensure the ordering of callbacks. By creating a
host level Lifecycle that is exactly nested outside
the callbacks to FragmentController, we can ensure
the proper nesting in callbacks.
Test: added test passes
Change-Id: I958d2389c90dcd9d157c6c3d30dffb689ed40c62
M fragment/src/androidTest/AndroidManifest.xml
M fragment/src/androidTest/java/androidx/fragment/app/OnBackPressedCallbackTest.kt
M fragment/src/main/java/androidx/fragment/app/FragmentActivity.java
https://android-review.googlesource.com/948209
https://goto.google.com/android-sha1/85c1de7395f07e3256a50706d4f619e654624250
Branch: androidx-master-dev
commit 85c1de7395f07e3256a50706d4f619e654624250
Author: Ian Lake <ilake@google.com>
Date: Fri Apr 19 13:54:21 2019
Ensure Fragment OnBackPressedCallbacks take priority
As FragmentController is not yet driven by a
LifecycleObserver (
Fragments are not necessarily nested within
LifecycleObservers registered at the Activity level.
This can lead to cases where a Fragment is started
before the Activity's Lifecycle is started.
In the case of FragmentManager's usage of Lifecycle to
add OnBackPressedCallbacks, that nesting is critical
to ensure the ordering of callbacks. By creating a
host level Lifecycle that is exactly nested outside
the callbacks to FragmentController, we can ensure
the proper nesting in callbacks.
Test: added test passes
Change-Id: I958d2389c90dcd9d157c6c3d30dffb689ed40c62
M fragment/src/androidTest/AndroidManifest.xml
M fragment/src/androidTest/java/androidx/fragment/app/OnBackPressedCallbackTest.kt
M fragment/src/main/java/androidx/fragment/app/FragmentActivity.java
ha...@gmail.com <ha...@gmail.com> #3
FWIW, I think this is a fantastic idea and would go a long way in bringing sanity to the world of lifecycle. As it would change the ordering between Activity lifecycle methods and Fragment lifecycle methods, this will almost certainly be an opt-in flag set at the FragmentActivity level.
Description
Component used: Navigation
Version used: 2.8.2
Devices/Android versions reproduced on: API level 34
Let's say
Home
is the start destination of the graph, it has an optional nav argument with default value""
, butstartDestination
uses a different argument.The problem:
When navigating by using
navController.navigate(Uri.parse("https://example.com"))
, the value ofsource
is its default value which is""
.But, when navigating by deep link either by using
startActivity
ornavController.handleDeepLink
, the value ofsource
is what defined instartDestination
which is"launcher"
.It happens only if
Home
is start destination. If it is not start destination, the behavior is consistent whether usingnavigate
or using deep link, the value is its default value which is""
.