Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit bcff8bdce11f6f7abfaf71296a667cf085d0705e
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Jul 29 08:46:36 2020
Throw error when registering for activity result after onCreate()
Attempting to register a callback for an activity result after
onCreate() of a fragment should not be supported.
ActivityResultCallbacks need to always be registered in a specific
order, even after recreation and process death.
Test: Added FragmentResultTests
Bug: 162255449
Change-Id: Iafd38f7f1d6b762613d904223baef71d425bc6bf
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentActivityResultTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
https://android-review.googlesource.com/1374647
Branch: androidx-master-dev
commit bcff8bdce11f6f7abfaf71296a667cf085d0705e
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Jul 29 08:46:36 2020
Throw error when registering for activity result after onCreate()
Attempting to register a callback for an activity result after
onCreate() of a fragment should not be supported.
ActivityResultCallbacks need to always be registered in a specific
order, even after recreation and process death.
Test: Added FragmentResultTests
Bug: 162255449
Change-Id: Iafd38f7f1d6b762613d904223baef71d425bc6bf
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentActivityResultTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
jb...@google.com <jb...@google.com> #3
This has been added internally and will be available in the Fragment 1.3.0-alpha08 release.
Description
When using the ActivityResultAPIs with fragment, the latest possible time that
registerForActivityResult()
should be called is inonCreate()
. Any calls made toregisterForActivityResult()
made afteronCreate()
will be ignored.Instead of ignoring these calls and allowing developers to assume that their callback is registered, we should throw an exception notifying that they are attempting to register too late.