In Android, i want to inject some dependency from an activity to fragment via bundle arguments. There is a concrete class having multiple nested complex objects.
There are 2 options :
- putParcelable(key, object)
- putBinder(key , object)
In option1, there are limitations of scaling for future scenarios as class can evolve and parceling works only for primitive types. We have to explicitly make each and every depenedency parcelable.
In option2, i will wrap the class object reference in binder and pass it is. And in fragment through getBinder, i will extract out the same reference.
How to pass an object from one activity to another on Android
In what cases we should use putBinder over putParcelable ? What are advantages of it ? As I believe putBinder can solve purpose passing any class reference without worrying about serialzing efforts , then what factors we need to think of before choosing Option1 vs option 2?