title: Android - LinkedHashMap cannot be passed between Activities
body: <p>I have a very strange problem. All I want to do is pass a <code>LinkedHashMap&lt;String,HashMap&lt;String,String&gt;&gt;</code> (I am just experimenting here and the I would like the choice of data structure to remain unchanged regardless of performance overhead) object from one Activity to another via an <code>Intent</code>. I tried two approaches after initializing and populating my data structure:</p>
  
  <pre><code> LinkedHashMap&lt;String,HashMap&lt;String,String&gt;&gt; mData = new LinkedHashMap&lt;String,HashMap&lt;String,String&gt;&gt;();
  //insert data into LinkedHashMap
  </code></pre>
  
  <p>Approach 1:</p>
  
  <pre><code> Intent intent = new Intent(this, TestActivity.class);             
   // as a Serializable
   intent.putExtra("DATA",mData)
   startActivity(intent);
  </code></pre>
  
  <p>Approach 2:</p>
  
  <pre><code> Intent intent = new Intent(this, TestActivity.class);             
   Bundle bundle = new Bundle();
   bundle.putSerializable("LIST",mData);
   intent.putExtra("DATA",bundle)
   startActivity(intent);
  </code></pre>
  
  <p>And in the receiving Activity:</p>
  
  <p>For Approach 1:</p>
  
  <pre><code>Intent intent = getIntent();
  mData = (LinkedHashMap&lt;String, HashMap&lt;String, String&gt;&gt;) intent.getSerializableExtra("DATA");
  </code></pre>
  
  <p>For Approach 2:</p>
  
  <pre><code>Intent intent = getIntent();
  Bundle bundle = intent.getBundleExtra("DATA");
  mData = (LinkedHashMap&lt;String, HashMap&lt;String, String&gt;&gt;) bundle.getSerializable("LIST");
  </code></pre>
  
  <p>And I keep running into this issue:</p>
  
  <pre><code> Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.LinkedHashMap
              at com.matchify.TestActivity.onCreate(TestActivity.java:56)
              at android.app.Activity.performCreate(Activity.java:5451)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
              at android.app.ActivityThread.access$900(ActivityThread.java:175)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:146)
              at android.app.ActivityThread.main(ActivityThread.java:5602)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>What am I doing wrong ? Apologies if I have missed something very obvious.</p>