Reputation: 5180
Can someone explain why this code doesn't work?
Intent i = new Intent(this.context, SomeClass.class);
HashMap<String, String> tmp1 = new HashMap<String, String>();
Log.d(TAG, "IN: " + String.valueOf(tmp1));
i.putExtra("VAR", tmp1);
HashMap<String, String> tmp2 = i.getParcelableExtra("VAR");
Log.d(TAG, "OUT: " + String.valueOf(tmp2));
What I expect to get:
tmp1
should equal tmp2
.What I actually get (LogCat):
VAR
expected Parcelable
but value was a java.util.HashMap
. The default value <null>
was returned.java.lang.ClassCastException: java.util.HashMap
Upvotes: 0
Views: 1821
Reputation: 31846
I think you are mistaken, HashMap
is not Parcelable
. It is however Serializable
, so you are putting a Serializable
extra and trying to read it as a Parcelable
, which causes the error.
Upvotes: 3