# parcelable

Parcelable is an Android mechanism that custom classes implement to serialize complex objects for transfer across activities and UI state using Bundles.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Do-It-Yourself Compose Multiplatform Navigation with Decompose

DevFeed: [Do-It-Yourself Compose Multiplatform Navigation with Decompose](<https://devfeed.tech/articles/do-it-yourself-compose-multiplatform-navigation-with-decompose-25916.md>)

Original publisher: [Read original article](<https://proandroiddev.com/diy-compose-multiplatform-navigation-with-decompose-94ac8126e6b5?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2023-02-09T09:02:35Z

Content type: tutorial

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [compose-multiplatform](<https://devfeed.tech/topics/compose-multiplatform.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [Library](<https://devfeed.tech/topics/library.md>), [parcelable](<https://devfeed.tech/topics/parcelable.md>), [Process](<https://devfeed.tech/topics/process.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [api](<https://devfeed.tech/tags/api.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [component](<https://devfeed.tech/tags/component.md>), [compose](<https://devfeed.tech/tags/compose.md>), [compose-multiplatform](<https://devfeed.tech/tags/compose-multiplatform.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [death](<https://devfeed.tech/tags/death.md>), [desktop](<https://devfeed.tech/tags/desktop.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [library](<https://devfeed.tech/tags/library.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [parcelable](<https://devfeed.tech/tags/parcelable.md>), [parcelize](<https://devfeed.tech/tags/parcelize.md>), [process](<https://devfeed.tech/tags/process.md>), [router](<https://devfeed.tech/tags/router.md>), [scope](<https://devfeed.tech/tags/scope.md>), [use-case](<https://devfeed.tech/tags/use-case.md>)

### AI overview

The article shows how to share Compose Multiplatform navigation between Android and Desktop using Decompose without adopting its full Component architecture. A `Router<C>` wraps Decompose's stack navigation and child stack; `RoutedContent` supplies each child's component context, and `rememberRouter` creates the stack. A `rememberViewModel` hook uses Essenty's `InstanceKeeper` to retain view models per screen and clear them when that screen leaves the stack. For process-death restoration, it pairs a `SavedStateHandle` with Essenty's `StateKeeper`; only Parcelable state can be retained this way. The approach lets the author keep a preferred architecture while using Decompose's navigation, lifecycle, and saved-state facilities. The excerpt says the implementation was also published as Decompose-Router and notes that other issues could still foil the approach.

### Source excerpt

How to survive configuration changes, survive process death and scope ViewModels without going all-in with Decompose 🫢 Decompose recently went 1.0.0 🙌. I think it's a good opportunity to share my specific use case with Decompose where I use it to share navigation logic between Android and Desktop, without going all in with Decompose's Component pattern. Here are some of the problems you would run into - in extracting the navigation to the shared code Abstraction of common navigation. Retaining and scoping your view models Restoring the view models state after the process death. Doesn't Decompose solve all these problems? Why not go all in? This was really just a preference. I wanted to do my own architecture for my app and an inheritance-based component approach wasn't my forte. Luckily Decompose allows you to use parts of it and couple your navigation with business logic (if you want to). Decompose provides you with extensive customisation options to tailor the library to your needs. That's what I ended up doing at the end An Update! 📰 I've decided to publish the implementations of this article as a library called Decompose-Router. This should save you some time if you want to implement this on your own app. If you don't care about the implementation details and just want to use the library, head over there. GitHub - xxfast/Decompose-Router: A Compose-multiplatform navigation library that leverage Decompose to create an API inspired by Conductor The Goal 🥅 This is what we will be working towards. @Parcelize sealed class Screen: Parcelable { object List : Screen() data class Details(val detail: String) : Screen() } @Composable fun ListDetailScreen() { val router: Router<Screen> = rememberRouter(listOf(List)) RoutedContent( router = router, animation = stackAnimation(slide()), ) { screen -> when (screen) { List -> ListScreen(onSelect { detail -> router.push(detail) } ) is Details -> DetailsScreen(screen.detail) } } } @Composable fun ListScreen(onSelect: (detail: Stri

## Simplified Android Development Using Simple-Stack

DevFeed: [Simplified Android Development Using Simple-Stack](<https://devfeed.tech/articles/simplified-android-development-using-simple-stack-25930.md>)

Original publisher: [Read original article](<https://medium.com/swlh/simplified-android-development-using-simple-stack-6e44ce808c35?source=rss-7a8d96da8cb6------2>)

Author: Gabor Varadi

Published: 2020-11-14T03:32:51Z

Content type: article

Language: en

Sources: [Gabor Varadi](<https://devfeed.tech/sources/stories-by-gabor-varadi-on-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [parcelable](<https://devfeed.tech/topics/parcelable.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [jetpack-navigation](<https://devfeed.tech/topics/jetpack-navigation.md>)

Tags: [2015](<https://devfeed.tech/tags/2015.md>), [2016](<https://devfeed.tech/tags/2016.md>), [2017](<https://devfeed.tech/tags/2017.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-apps](<https://devfeed.tech/tags/android-apps.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [approach](<https://devfeed.tech/tags/approach.md>), [classes](<https://devfeed.tech/tags/classes.md>), [flow](<https://devfeed.tech/tags/flow.md>), [fork](<https://devfeed.tech/tags/fork.md>), [fragment](<https://devfeed.tech/tags/fragment.md>), [fragments](<https://devfeed.tech/tags/fragments.md>), [framework](<https://devfeed.tech/tags/framework.md>), [keys](<https://devfeed.tech/tags/keys.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [original](<https://devfeed.tech/tags/original.md>), [parcelable](<https://devfeed.tech/tags/parcelable.md>), [rewrite](<https://devfeed.tech/tags/rewrite.md>), [simple-stack](<https://devfeed.tech/tags/simple-stack.md>), [square](<https://devfeed.tech/tags/square.md>), [state](<https://devfeed.tech/tags/state.md>)

### AI overview

Simple-Stack tracks navigation as a back stack of immutable, Parcelable screen identifiers called keys. The article's example describes navigating by calling a method such as `backstack.goTo(new SecondScreen(detailId))`, with the framework abstracting fragment transactions and argument Bundles. Its author says the library grew from experience with Flow and Mortar: maintaining a fork and encountering limitations motivated a rewrite intended to be reliable, versioned, and improved. The excerpt introduces type-safe Fragment navigation but cuts off before showing setup steps.

### Source excerpt

It's been a long time since I've wanted to write this article. Time to go at it, shall we? :) People always seem to be surprised and say, "wait, you DON'T use Jetpack ViewModel, Jetpack Navigation, and Dagger-Hilt? Then what DO you use?" This article intends to answer that. We use Simple-Stack. (If you prefer watching talks, then a talk on the same subject is available at https://www.youtube.com/watch?v=5ACcin1Z2HQ) What is Simple-Stack? Simple-Stack is a navigation framework that I've been working on since the beginning of 2017, although its roots go back to 2015 -- when we were still experimenting with multiple versions of Mortar & Flow. (The 90s kids might still remember). Following up on the original proposition by Square, "Advocating Against Android Fragments" and "Simpler Android Apps with Flow and Mortar", we've been using Single-Activity approach in our apps since 2015. Now, the history of Flow and Mortar isn't all roses. I've heard people say "we tried it and it didn't work for us". I can attest to that: we had to manage our own fork, but even with that, we hit some of its limitations over time. We needed something reliable and versioned, so we rewrote Flow's original behavior, and intended to improve upon its limitations. This rewrite is what resulted in the creation of Simple-Stack. Why Simple-Stack? Simple-Stack is based on the idea that you intend to track your navigation state as a list of immutable and Parcelable classes -- screen identifiers (which the library calls "keys"). As long as the underlying navigation implementation allows for "navigation from any state to any state", it is possible to wrap that implementation using Simple-Stack. For example, something I hear often is that "navigation with Fragments is hard". I always point out that in our code, it's been like this since 2016: backstack.goTo(new SecondScreen(detailId)); // java No explicit fragment transaction, no Bundle, no newInstance(), just calling a method. How is this possible? Isn't Fr

## A study of the Parcelize feature from Kotlin Android Extensions

DevFeed: [A study of the Parcelize feature from Kotlin Android Extensions](<https://devfeed.tech/articles/a-study-of-the-parcelize-feature-from-kotlin-android-extensions-25876.md>)

Original publisher: [Read original article](<https://bladecoder.medium.com/a-study-of-the-parcelize-feature-from-kotlin-android-extensions-59a5adcd5909?source=rss-54910f05af37------2>)

Author: Christophe Beyls

Published: 2019-11-19T07:31:01Z

Content type: article

Language: en

Sources: [Christophe Beyls](<https://devfeed.tech/sources/stories-by-christophe-beyls-on-medium.md>)

Topics: [parcelable](<https://devfeed.tech/topics/parcelable.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [annotation](<https://devfeed.tech/tags/annotation.md>), [code-generation](<https://devfeed.tech/tags/code-generation.md>), [google](<https://devfeed.tech/tags/google.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [gradle-plugin](<https://devfeed.tech/tags/gradle-plugin.md>), [jetbrains](<https://devfeed.tech/tags/jetbrains.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-android-extensions](<https://devfeed.tech/tags/kotlin-android-extensions.md>), [kotlin-programming](<https://devfeed.tech/tags/kotlin-programming.md>), [parcelable](<https://devfeed.tech/tags/parcelable.md>), [parcelize](<https://devfeed.tech/tags/parcelize.md>), [plugin](<https://devfeed.tech/tags/plugin.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>)

### AI overview

The article presents Kotlin's `@Parcelize` as a production-ready way to generate efficient Android `Parcelable` implementations, with no runtime library overhead or extra methods. It covers setup across Kotlin versions (the separate `kotlin-parcelize` plugin from Kotlin 1.4.20), supported types, generated serialization behavior, and practical constraints. Built-in handling covers primitives, strings, many collections, and nested parcelables; unsupported custom types need a `Parceler` to avoid slow `Serializable` fallback or runtime failure. Nullable custom types require matching nullable-type annotations. Other caveats include unsupported AndroidX collection types, inability to parcelize abstract or sealed classes directly, repeated serialization of inherited fields in annotated subclasses, and generated `CREATOR` fields being unavailable for Kotlin references during compilation. The article gives workarounds, including custom serializers, standard collections, and manual implementations where needed.

### Source excerpt

Life is too short to waste time on writing Parcelable code Two years ago, I wrote about how you can leverage features of the Kotlin programming language to manually write your Android Parcelable implementations in the most concise and readable way. Does it mean that I always prefer writing this code manually rather than letting a library or tool generate it for me? Of course not: like most developers, I believe that the best code is the code you don't have to write. But I expect the tools I use to meet my quality standards. That's why I tend to be conservative about the dependencies I add to my projects and will always favor official libraries from Jetbrains or Google over third-party solutions. Things have changed for the better since I wrote the previous article: with the release of Kotlin 1.3.40, @Parcelize is now a stable feature provided by the Parcelize Gradle plugin (formerly known as Kotlin Android Extensions). And since version 1.3.60, the Android Studio plugin also properly recognizes the feature as non-experimental so it can finally be considered as production-ready. I previously enumerated a list of some of the negative aspects of third-party Parcelable code generation libraries compared to manual implementation. Here's why I believe @Parcelize stands out from the rest in regard to that list: It's an official plugin made by JetBrains with the collaboration of Google and is guaranteed to be well supported in the future The generated code of @Parcelize is very efficient (as we'll discover further in this article) The CREATOR field doesn't have to be declared at all, along with that easy-to-forget @JvmField annotation Thanks to the Parceler interface, it is possible to write simple plugins to handle unsupported types or override the default implementation No extra classes are created by the plugin. All the generated code is embedded in the annotated class so the app will behave exactly as if you wrote the code yourself There is no runtime library overhead a

## Note to Future Me -- Testing Intents with Matchers

DevFeed: [Note to Future Me -- Testing Intents with Matchers](<https://devfeed.tech/articles/note-to-future-me-testing-intents-with-matchers-32073.md>)

Original publisher: [Read original article](<https://www.maiatoday.net/p/note-to-future-me-testing-intents-with-matchers/>)

Published: 2018-01-26T14:54:45Z

Content type: tutorial

Language: en

Sources: [Maiatoday](<https://devfeed.tech/sources/maiatoday.md>)

Topics: [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [test](<https://devfeed.tech/topics/test.md>), [parcelable](<https://devfeed.tech/topics/parcelable.md>), [Code](<https://devfeed.tech/topics/code.md>), [Library](<https://devfeed.tech/topics/library.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [data](<https://devfeed.tech/tags/data.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [error-messages](<https://devfeed.tech/tags/error-messages.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [library](<https://devfeed.tech/tags/library.md>), [parcelable](<https://devfeed.tech/tags/parcelable.md>), [testing](<https://devfeed.tech/tags/testing.md>), [testing-matchers](<https://devfeed.tech/tags/testing-matchers.md>), [tests](<https://devfeed.tech/tags/tests.md>)

### AI overview

This tutorial demonstrates testing Android activity intents with Espresso and Hamcrest matchers in Kotlin. It passes a parcelable data object between activities, verifies the intent extra and its properties, and shows how custom matchers can improve error messages and test only selected properties.

### Source excerpt

I want to make my little experiments public and save them as a reminder for future me. So here is yet another post on Matchers and Espresso testing. I want to test this: First activity starts another activity at a button click. First activity passes a parcelable object to the second activity. Test that the intent that starts the second activity contains the object with the correct properties. I built a contrived example, MainActivity collects some info and passes this to StarActivity in a parcelable called ContrivedParams. See the sample code on GitHub. To write the tests I brushed up on Hamcrest[1][2][3]: a library that makes it easier to write readable tests. Instead of assert(expected==actual) you can write almost-english assertThat(actual, is(expected)) which is a sugar coated version of assertThat(actual is(equalto(expected))) Sadly though is is a hard keyword in Kotlin so I ended up using the isA() and equalTo() varieties of calls rather than escaping is with backticks. Another reason to use Hamcrest -- better error messages. Compare these two messages. java.lang.AssertionError at net.maiatoday.hellointentmatcher.ContrivedParamsTest.showErroMessagesTest(ContrivedParamsTest.kt:37) with the message given by a custom matcher java.lang.AssertionError: Expected: title should return "Hello World" but: was "Hello World!" at net.maiatoday.hellointentmatcher.ContrivedParamsTest.showErroMessagesTest(ContrivedParamsTest.kt:42) or the error message given by an object matcher java.lang.AssertionError: Expected: <ContrivedParams(title=Hello World, starCount=3, colour=#00b0ff)> but: was <ContrivedParams(title=Hello World!, starCount=4, colour=#00b0fff)> at net.maiatoday.hellointentmatcher.ContrivedParamsTest.showErroMessagesTest(ContrivedParamsTest.kt:47) The parameters for the second activity is passed in a parcelable data class. I used the Espresso-intents library . Start the activity with an IntentsTestRule. The IntentsTestRule initialises the Espresso intents before each