In my android application I have an activity containing a Parcelable
object (implements Parcelable
).
That object contains a map.
When I try to do the following in the writeToParcel()
method:
parcel.writeMap(myMap);
I get the following comment from the API:
Please use writeBundle(Bundle) instead. Flattens a Map into the parcel at the current dataPosition(), growing dataCapacity() if needed. The Map keys must be String objects. The Map values are written using writeValue(Object) and must follow the specification there.
How am I supposed to do it?
How am I supposed to use the writeBundle(myMap)
here?
Bundle is just a map. Iterate through your map, put each mapping into a newly created Bundle object and call writeBundle over it. May not be the best solution, but, a workable solution.
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