wrygiel
wrygiel

Reputation: 5180

Weird behaviour of getParcelableExtra (Key X expected Parcelable but value was a Y)

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:

What I actually get (LogCat):

Upvotes: 0

Views: 1821

Answers (1)

Jave
Jave

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

Related Questions