I’m using the following code to read a map of type HashMap<String, String> from a Parcel:
in.readHashMap(HashMap.class.getClassLoader());
This seems to work just fine, but I get a warning:
Type safety: The expression of type HashMap needs unchecked conversion to conform to Map<String,String>
Is there a “right” way to do this, use a different class loader? Or should I just go with @SuppressWarnings("unchecked")?
The Android developer documentation for
Parcel.readHashMap()says:So maybe you should be using
readBundle()andwriteBundle()instead.