Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 9fe209b0b6489fc3eba5be3c646beaf0efe8ed7e
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Aug 25 11:55:49 2020
Remove observers when unregistering ActivityResult
Currently, if you register an ActivityResult using a LifecycleOwner and
then go through process death, we add an Observer to fire the registered
callback once the lifecycle goes to STARTED. In the case of
unregistering, we should make sure to remove any observers that may have
been added.
Test: Added ActivityResultRegistryTest#testLifecycleOwnerCallbackUnregistered
Bug: 165608393
Change-Id: If81142b1a6abc72b105986a2460e4aeb96e29eaf
M activity/activity/src/androidTest/java/androidx/activity/result/ActivityResultRegistryTest.kt
M activity/activity/src/main/java/androidx/activity/result/ActivityResultRegistry.java
https://android-review.googlesource.com/1410730
Branch: androidx-master-dev
commit 9fe209b0b6489fc3eba5be3c646beaf0efe8ed7e
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Aug 25 11:55:49 2020
Remove observers when unregistering ActivityResult
Currently, if you register an ActivityResult using a LifecycleOwner and
then go through process death, we add an Observer to fire the registered
callback once the lifecycle goes to STARTED. In the case of
unregistering, we should make sure to remove any observers that may have
been added.
Test: Added ActivityResultRegistryTest#testLifecycleOwnerCallbackUnregistered
Bug: 165608393
Change-Id: If81142b1a6abc72b105986a2460e4aeb96e29eaf
M activity/activity/src/androidTest/java/androidx/activity/result/ActivityResultRegistryTest.kt
M activity/activity/src/main/java/androidx/activity/result/ActivityResultRegistry.java
jb...@google.com <jb...@google.com> #3
This has been fixed internally and will be available in the next release of Fragments.
Description
Component used: Activity Version used: 1.2.0-alpha07
If you register for a result with a
LifecycleOwner
and your activity goes through process death and restoration, once it is created again if there is already result a waiting to be returned to theLifecycleOwner
an observer is added to wait until theLifecycle
isSTARTED
. When the lifecycle owner is unregistered, the observer is never removed.We should keep track of any observers added to the
LifecycleOwner
and remove them if the callback for the lifecycle owner is ever unregistered.