I m using a Map
of String and Pojo
. I m implementing Parcelable
in that class
. To generate parcelable
I m using plugin Android Parcelable code generator
by Michal Charmas. It's working fine for everything else, but not for Map<String, Object>
. Here is my code
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.driverDocuments.size());
for (Map.Entry<String, Document> entry : this.driverDocuments.entrySet()) {
dest.writeString(entry.getKey());
dest.writeSerializable(entry.getValue());
}
}
Off course if the map is null, it will throw null pointer. But if we apply the null check, it will miss the map when it's null
. So I'm thinking of the proper recommended way to parcel Map. Anyone suggestion ?