Which classloader to use with Parcel.readHashMap?

I use the following code to read the card type HashMap<String, String > with the premise:

 in.readHashMap(HashMap.class.getClassLoader()); 

Everything seems to be working 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 classloader? Or should I just go with @SuppressWarnings("unchecked" )?

+6
source share
1 answer

Android developer documentation for Parcel.readHashMap() says:

Instead, use readBundle(ClassLoader) (whose data should have been written using writeBundle(Bundle) .

So, perhaps you should use readBundle() and writeBundle() .

+6
source

Source: https://habr.com/ru/post/916685/


All Articles