Savedstate
| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |
|---|---|---|---|---|
| June 29, 2022 | 1.2.0 | - | - | - |
Declaring dependencies
To add a dependency on SavedState, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle file for
your app or module:
Groovy
dependencies {
// Java language implementation
implementation "androidx.savedstate:savedstate:1.2.0"
// Kotlin
implementation "androidx.savedstate:savedstate-ktx:1.2.0"
}
Kotlin
dependencies {
// Java language implementation
implementation("androidx.savedstate:savedstate:1.2.0")
// Kotlin
implementation("androidx.savedstate:savedstate-ktx:1.2.0")
}
For more information about dependencies, see Add build dependencies.
Feedback
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
Version 1.2.0
Version 1.2.0
June 29, 2022
androidx.savedstate:savedstate:1.2.0 and androidx.savedstate:savedstate-ktx:1.2.0 are released. Version 1.2.0 contains these commits.
Important changes since 1.1.0
SavedStateRegistryControllernow allows early attachment of theSavedStateRegistryviaperformAttach().- You can now retrieve a previously registered
SavedStateProviderfrom aSavedStateRegistryviagetSavedStateProvider(). - The
SavedStatelibrary has been rewritten in Kotlin.- For
SavedStateRegistryOwner, this is a source incompatible change for those classes written in Kotlin - you must now override thesavedStateRegistryproperty rather than implement the previousgetSavedStateRegistry()function. - For
ViewTreeSavedStateRegistryOwner, this is a source incompatible change for those classes written in Kotlin - you must now directly import and use the Kotlin extension methods onViewofandroidx.savedstate.setViewTreeSavedStateRegistryOwnerandandroidx.savedstate.findViewTreeSavedStateRegistryOwnerto set and find a previously set owner. This replaces thesavedstate-ktxAPI offindViewTreeSavedStateRegistryOwner.
- For
Behavior Changes
SavedStateRegistryno longer saves an empty Bundle if there is no state to save.
Version 1.2.0-rc01
May 11, 2022
androidx.savedstate:savedstate:1.2.0-rc01 and androidx.savedstate:savedstate-ktx:1.2.0-rc01 are released. Version 1.2.0-rc01 contains these commits.
Documentation Changes
- The
SavedStateRegistryOwnerKdocs have been updated to clarify the responsibilities and contract that the owner has on how it should implement the interface or when they should call the methods onSavedStateRegistryController. (Iefc95, b/228887344)
Version 1.2.0-beta01
April 20, 2022
androidx.savedstate:savedstate:1.2.0-beta01 and androidx.savedstate:savedstate-ktx:1.2.0-beta01 are released. Version 1.2.0-beta01 contains these commits.
API Changes
- The
SavedStateRegistryandViewTreeSavedStateRegistryOwnerclasses have been rewritten in Kotlin. ForViewTreeSavedStateRegistryOwner, this is a source incompatible change for those classes written in Kotlin - you must now directly import and use the Kotlin extension methods onViewofandroidx.savedstate.setViewTreeSavedStateRegistryOwnerandandroidx.savedstate.findViewTreeSavedStateRegistryOwnerto set and find a previously set owner. This replaces thesavedstate-ktxAPI offindViewTreeSavedStateRegistryOwner. This is binary compatible and remains source compatible for implementations written in the Java programming language. (b/220191285)
Version 1.2.0-alpha02
April 6, 2022
androidx.savedstate:savedstate:1.2.0-alpha02 and androidx.savedstate:savedstate-ktx:1.2.0-alpha02 are released. Version 1.2.0-alpha02 contains these commits.
New Features
- You can now retrieve a previously registered
SavedStateProviderfrom aSavedStateRegistryviagetSavedStateProvider(). (I7ea47, b/215406268)
API Changes
- The
SavedStateRegistryOwner,SavedStateRegistryController, andRecreatorclasses have been rewritten in Kotlin. ForSavedStateRegistryOwner, this is a source incompatible change for those classes written in Kotlin - you must now override thesavedStateRegistryproperty rather than implement the previousgetSavedStateRegistry()function. This is binary compatible and source compatible for implementations written in the Java programming language. (b/220191285)
Version 1.2.0-alpha01
January 26, 2022
androidx.savedstate:savedstate:1.2.0-alpha01 and androidx.savedstate:savedstate-ktx:1.2.0-alpha01 are released. Version 1.2.0-alpha01 contains these commits.
New Features
SavedStateRegistryControllernow allows early attachment of theSavedStateRegistryviaperformAttach(). (Ice4bf)
Behavior Changes
SavedStateRegistryno longer saves an empty Bundle if there is no state to save. (aosp/1896865, b/203457956)
Version 1.1.0
Version 1.1.0
February 10, 2021
androidx.savedstate:savedstate:1.1.0 and androidx.savedstate:savedstate-ktx:1.1.0 are released. Version 1.1.0 contains these commits.
Major changes since 1.0.0
ViewTreeSavedStateRegistryOwnerAPI: A newViewTreeSavedStateRegistryOwner.get(View)API allows you to retrieve the containingSavedStateRegistrygiven aViewinstance. You must upgrade to Activity1.2.0, Fragment1.3.0, and AppCompat1.3.0-alpha01or higher to populate this correctly.savedstate-ktxartifact: The newsavedstate-ktxartifact has been added with afindViewTreeSavedStateRegistryOwner()Kotlin extension for working withViewTreeSavedStateRegistryOwner.
Version 1.1.0-rc01
December 16, 2020
androidx.savedstate:savedstate:1.1.0-rc01 and androidx.savedstate:savedstate-ktx:1.1.0-rc01 are released with no changes since 1.1.0-beta01. Version 1.1.0-rc01 contains these commits.
Version 1.1.0-beta01
October 1, 2020
androidx.savedstate:savedstate:1.1.0-beta01 and androidx.savedstate:savedstate-ktx:1.1.0-beta01 are released with no changes since 1.1.0-alpha01. Version 1.1.0-beta01 contains these commits.
Version 1.1.0-alpha01
May 20, 2020
androidx.savedstate:savedstate:1.1.0-alpha01 and androidx.savedstate:savedstate-ktx:1.1.0-alpha01 are released. Version 1.1.0-alpha01 contains these commits.
New Features
- A new
ViewTreeSavedStateRegistryOwner.get(View)API allows you to retrieve the containingSavedStateRegistrygiven aViewinstance. You must upgrade to Activity1.2.0-alpha05, Fragment1.3.0-alpha05, and AppCompat1.3.0-alpha01to populate this correctly. (aosp/1298679) - The new
savedstate-ktxartifact has been added with afindViewTreeSavedStateRegistryOwner()Kotlin extension for working withViewTreeSavedStateRegistryOwner. (aosp/1299434)
Version 1.0.0
Version 1.0.0
September 5, 2019
androidx.savedstate:savedstate:1.0.0 is released. The commits included in this version can be found here.
Major features of SavedState 1.0.0
androidx.savedstate graduated to a stable release. This is a set of APIs that allow developers to plugin components into the restore / saveInstanceState process. The main entry point of the API is SavedStateRegistry, which provides a way to retrieve previously saved states using consumeRestoredStateForKey and register a callback to registerSavedStateProvider to provide a saved state once system requests it.
Version 1.0.0-rc01
July 2, 2019
androidx.savedstate:savedstate:1.0.0-rc01 is released. The commits included in this version can be found here.
Bug fixes
- Fixed incorrect proguard rule (b/132655499)
Version 1.0.0-beta01
May 7, 2019
androidx.savedstate:savedstate:1.0.0-beta01 is released. The commits included in this version can be found here.
Version 1.0.0-alpha02
March 13, 2019
androidx.savedstate:savedstate:1.0.0-alpha02 is released. androidx.savedstate:savedstate combines artifacts androidx.savedstate:savedstate-bundle and androidx.savedstate:savedstate-common into one artifact, because it was decided to simplify savedstate infrastructure and remove generics from SavedStateRegistry. Thus, there is no need for separate modules.
The full list of commits included in this version can be found here.
New features
SavedStateRegistry.runOnNextRecreaction(Class<? extends AutoRecreated> clazz )was added. The given class will be instantiated and the methodAutoRecreated.onRecreatedwill be run when the owning component restarted.
API changes
- Generics removed from
SavedStateRegistry<T> - AbstractSavedStateRegistry & BundlableSavedStateRegistry are removed, use simple
SavedStateRegistryinstead BundleSavedStateRegistryOwneris renamed toSavedStateRegistryOwner
Version 1.0.0-alpha01
December 17, 2018
This is the first release of SavedState.
New features
androidx.savedstate is a new set of alpha APIs that allow developers to plugin components to the restore / saveInstanceState process. The main entry point of the API is SavedStateRegistry<T>, which provides a way to retrieve previously savedstate via consumeRestoredStateForKey and register a callback to registerSavedStateProvider to provide a savedstate once system requests it.

