I have an activity that has a hashmap of 15 items. I want to pass it to another activity that uses those items. I am aware that using the Parcelable class is more efficient than serialising. However I wonder if there is any point or much value in creating an object to do the "parceling" and using intent.putExtra to pass it to the activity that requires it. It seems a little long and unnecessary or round about way of doing something - but I don't want the activity to implement parcelable because it isn't good for the design of the application (in my opinion) any advice or opinions on this way of doing it would be very much appreciated.
Asked
Active
Viewed 341 times
0
-
1"but I don't want the activity to implement parcelable" I thought you only want to transport a hashmap, not the entire activity? – zapl Dec 08 '13 at 22:43
-
Yes but I don't have to create another object to do the parceling and send it off do I? Seems a little long... – user2405469 Dec 08 '13 at 22:44
-
See that is what I wanted to avoid, creating another object to do parceling, but you have suggested serializable and I have been reading that it isn't as efficient as using parcelable... – user2405469 Dec 08 '13 at 22:50
-
2If you have a `HashMap` you don't need to do so. `HashMap` implements `Serializable` already. See [this question](http://stackoverflow.com/questions/11452859/android-hashmap-in-bundle). But you have to make sure that every object contained in the map also implements `Serializable` or you'll get [this problem](http://stackoverflow.com/questions/6035381/serializable-parcelable-issue-runtimeexception-parcelable-encountered-ioexcept) – zapl Dec 08 '13 at 22:55