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:
- HashMap is parcellable.
tmp1
should equaltmp2
.
What I actually get (LogCat):
- Debug: IN: {}
- Warning: Key
VAR
expectedParcelable
but value was ajava.util.HashMap
. The default value<null>
was returned. - Warning: Attempt to cast generated internal exception:
java.lang.ClassCastException: java.util.HashMap
- Debug: OUT: null