June 5, 2019
androidx.fragment:fragment-testing:1.1.0-beta01 are released. The commits included in this version can be found here.
androidx.lifecycle.Lifecyclecallbacks (specifically related to
DESTROYED) for nested Fragments are now properly nested. (b/133497591)
OnBackPressedCallbackinstances registered in a Fragment’s
onCreate()now properly take precedence over the child FragmentManager. (b/133175997)
- Child fragments are no longer animated when their parent fragment is being replaced. (b/121017790)
- Fragments animations and transitions are now ignored when using
animateLayoutChanges="true", fixing an issue where Fragments were not properly destroyed. (b/116257087)
May 16, 2019
androidx.fragment:fragment-testing:1.1.0-alpha09 are released. The commits included in this version can be found here.
- Fragments now receive a callback to a new
onPrimaryNavigationFragmentChanged(boolean)method when the primary navigation fragment changes. aosp/960857
- Menu Items inflated by a child Fragment are now correctly removed when the Parent Fragment is removed. b/131581013
May 7, 2019
androidx.fragment:fragment-testing:1.1.0-alpha08 are released. The commits included in this version can be found here.
This release is incompatible with Preferences 1.1.0-alpha01 through 1.1.0-alpha04. Please upgrade to Preferences 1.1.0-alpha05 when using this version of Fragments.
- Added a new overload of
postponeEnterTransition()that takes a timeout, after which the Fragment will automatically call
- Breaking change: the previously deprecated
instantiatemethod that took a
Bundlehas been removed. aosp/953856
- Breaking change: The
FragmentStatePagerAdapterhave been renamed to
BEHAVIOR_SET_USER_VISIBLE_HINT, respectively. aosp/954782
- Fragments that have had their lifecycle capped via
setMaxLifecycle()no longer get resumed before reaching their final state. b/131557151
- When using
setMaxLifecycle(Lifecycle.State.CREATED), Fragments will properly have their view destroyed. aosp/954180
April 25, 2019
androidx.fragment:fragment-testing:1.1.0-alpha07 are released. The commits included in this version can be found here.
- You can now set a max Lifecycle state for a Fragment by calling
FragmentTransaction. This replaces the now deprecated
FragmentStatePagerAdapterhave a new constructor that allows you to switch to the new behavior. (b/129780800)
FragmentScenariocan now only be called on API 24+ devices. (b/129880016)
- As a consequence of (b/129907905), fragments on the back stack will not get a callback to
onCreateView()when the hosting activity is recreated.
onCreateView()will now only be called when the fragment becomes visible (i.e., the back stack is popped).
- Fixed an issue when using a
<fragment>tag in XML and the
- Corrected an issue where fragments on the back stack would not be moved to at least
CREATEDafter a configuration change, causing ViewModels and child retained fragments to not be properly disposed. (b/129593351)
- Fixed a crash in
restoreSaveStatecaused by a desync of the retained fragments after the instance state is saved. (b/130433793) (aosp/947824)
- Fixed issues where an
OnBackPressedCallbackadded with a fragment lifecycle would not be called if the
FragmentManagerhad a back stack. See androidx.activity 1.0.0-alpha07 for more details. (aosp/948209)
- Fragments no longer enforce
LAYER_TYPE_HARDWAREfor animations. If you specifically need a hardware layer animation, please set it as part of your animation. (b/129486478)
April 3, 2019
androidx.fragment:fragment-testing:1.1.0-alpha06 are released. The commits included in this version can be found here.
- Exceptions thrown by FragmentManager now include the Fragment’s name in the message. (b/67759402)
FragmentActivitynow contain a second constructor that takes a
@LayoutRes int, which replaces the previous behavior of annotating your class with
@ContentView. This approach works in both app and library modules. (b/128352521)
onActivityResult()is now properly marked as
- The FragmentFactory’s
instantiatemethod that takes an argument Bundle has been deprecated and apps should use the new
instantiateoverload that does not take a Bundle. (b/128836103)
FragmentScenariomethods are now properly annotated with
FragmentTabHosthas been deprecated. (b/127971835)
getThemedContext()has been removed. (aosp/934078)
- Fixed a regression in 1.1.0-alpha05 that caused the incoming Fragment to flash on the screen. (b/129405432)
- Fixed an issue where the primary navigation fragment would be lost after a popBackStack+replace+popBackStack series of operations. (b/124332597)
- Fixed an issue when using
@ContentViewconstructors on your Activity when restoring Fragment state. (b/127313094)
- Corrected the logic of
setTargetFragment()when replacing an existing target Fragment with a Fragment not yet attached to the FragmentManager. (aosp/932156)
March 13, 2019
androidx.fragment:fragment-testing:1.1.0-alpha05 are released. The full list of commits included in this version can be found here.
@ContentViewannotation lookups are now cached (b/123709449)
setPrimaryNavigationFragment()with a Fragment attached to a different FragmentManager now throws an
IllegalStateExceptionrather than silently failing (aosp/904301)
FragmentActivityis now correctly marked with
- Fixed an issue where
onDismiss()could be called twice when using
February 7, 2019
androidx.fragment:fragment-ktx 1.1.0-alpha04, and
androidx.fragment:fragment-testing 1.1.0-alpha04 are released.
- Added support for the
@ContentViewclass annotation that allows you to indicate which layout XML file should be inflated as an alternative to overriding
onCreateView(). It is recommended to do view related work in
fragment-testingnow depends on
androidx.test:core-ktx1.1.0 stable (b/121209673)
- You can now use
FragmentScenarioto test Fragment hosted options menus (b/121126668)
- Added a
requireArguments()method which returns a
@NonNull Bundleor throws an
- Added a note that
getViewLifecycleOwnerLiveData()should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. (aosp/880714)
- Added a note that
getViewModelStore()should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. (aosp/880713)
- Fixed an issue with binary compatibility with previous releases of Fragments. (aosp/887877) (aosp/889834)
- Target fragments are correctly cleared out when you pass
- Fixed an issue where target Fragments were sometimes unavailable in or after
- DialogFragment’s onDismiss() is now called before
onDestroy(). (aosp/874133) (aosp/890734)
December 17, 2018
- Fragment now implements
BundleSavedStateRegistryOwnerand depends on the newly released SavedState library [aosp/824380]
by activityViewModelsKotlin property delegate has been added to retrieve ViewModels associated with the containing Activity [b/119050253]
by viewModelsKotlin property delegate has been expanded to take an optional lambda method for getting the
ViewModelStoreOwner, allowing you to pass in the parent Fragment or other custom
ViewModelStoreOwnerwith code such as
val viewModel: MyViewModel by viewModels(::requireParentFragment)[b/119050253]
FragmentScenarionow allows you to specify a theme such as
Theme.AppCompat[b/119054431]. This is a breaking change.
- Added a
requireView()method which returns a
@NonNull Viewor throws an
- Added a
requireParentFragment()method which returns a
@NonNull Fragmentor throws an
- Fixed IllegalStateException: Failure saving state b/120814739
- Fragments being restored from saved instance state will now always receive a non-null
- Removed Fragments no longer reuse their
Lifecycleobject if re-added [b/118880674]
December 3, 2018
- FragmentScenario’s Kotlin extensions now let you use a lambda for Fragment construction as an alternative to passing in a
- Fixed an IllegalStateException when using nested Fragments on the back stack (b/119256498)
- Fixed crash when using
- Fixed an issue where target Fragments were not accessible after the Fragment was removed (aosp/807634)
November 5, 2018
This is the first release of the
fragment-testing artifact and
FragmentScenario which is built on top of the
androidx.test:core APIs. See the Fragment testing documentation for more details.
- New FragmentScenario class for testing Fragments in isolation.
- You can now set a
FragmentManagerto control how new Fragment instances are instantiated.
- Added a new
by viewModels()Kotlin property delegate for retrieving ViewModels from a Fragment.
- Pending input events (such as clicks) are now canceled in a Fragment’s
- Significantly expanded the nullability annotations across the Fragment API surface.
- Fix an issue which caused Fragment operations to fail from within LiveData (b/77944637)
- Target Fragments cannot be accessed after a Fragment has been removed from the FragmentManager.
androidx.test:core:1.0.0-beta01instead of the correct