I want to use Parcelable with the Navigation Components and Safe Args in version 1.0.0-alpha07
. Although since alpha 03 Parcelable should be supported by Safe Args, but I'm not able to use them. The only way to use it is with app:argType="android.os.Parcelable"
which doesn't seem like the right way for me.
If I use only app:argType="Parcelable"
there is no import generated in the generated classes.
Therefore what's the right way to use Parcelable with Safe Args?
Safe Args is strongly recommended for navigating and passing data, because it ensures type-safety. In some cases, for example if you are not using Gradle, you can't use the Safe Args plugin. In these cases, you can use Bundles to directly pass data. You must also apply one of two available plugins.
What does the Safe Args Gradle plugin do? Select all that apply. Choose as many answers as you see fit. Generates simple object and builder classes for type-safe access to arguments specified for destinations and actions.
You need Android Studio 3.3 and above. Create parcelable object, then go to navigation editor, select destination for which you want to create argument. Then click on add icon on arguments section on the right:
Then select custom parcelable from drop down list:
And choose your parcelable class:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With