BridgeAn open source library for avoiding the pitfalls of Android state saving and restoration.
Why we built it.
Many Android developers have long leveraged the Android state saving and restoration framework to save network-related data to avoid unnecessary network requests after configuration changes and when restoring apps from a background state. There was always a limitation to the amount of data that could be saved, but that limit originally manifested as a silent failure to properly save and restore state---a graceful outcome that most developers could tolerate. In Android Nougat, however, many developers were completely blindsided when that limitation was upgraded to a hard crash via the infamous TransactionTooLargeException.
While Google introduced new guidance on how to avoid situations like these with the introduction of the Android Architecture Components, we at Livefront felt it was necessary to also provide a tool that solves this problem with as little code change as possible. This not only helps to quickly solve the problem on existing projects without a significant code refactor, but is valuable to any new project that wants to handle state saving and restoration in a more traditional way without the need for manually creating and maintaining a local database.
How does it work?
Rather than sending your saved data to the Android OS, Bridge stores your data as a Bundle in memory (for quick retrieval after configuration changes) and employs a simple trick to generically write Bundles to disk (for access after process death and restoration). In order to match Activities and Fragments with the corresponding saved data managed by Bridge, Bridge also hooks into the existing saved state framework to store and retrieve keys that uniquely identity that state. In this way, Bridge works both with and around the Android OS state saving framework in order to provide the best possible results. For more details, check out our our Medium article!
How do I use it?
Using Bridge is simple, especially if you are already using or are familiar with annotation-based state saving frameworks like Icepick. Check out the project on GitHub for more details.
We are Livefront.
Our team creates beautiful mobile apps for people in motion. We work every day with Fortune 500 companies and startups alike to build custom software for phones, tablets, mobile payment wallets, and wearables like watches and glasses. We care deeply about quality, and we love what we do.