title: Android - startActivityForResult onActivityResult get ArrayList back
body: <p>This is how I send an ArrayList:</p>
  <pre><code>val extras = Bundle()
  
  val i = Intent(context, GalleryShow::class.java)
  i.putExtra(&quot;list&quot;, ArrayList(memes))
  (context as Activity).startActivityForResult(i, 777)
  </code></pre>
  <p>and receive it in Activity B:</p>
  <pre><code>intent.getParcelableArrayListExtra&lt;Memes&gt;(&quot;list&quot;) as ArrayList&lt;Memes&gt;
  </code></pre>
  <p>then after modifying it I set the intent that suppose to go back to Activity A:</p>
  <pre><code>private lateinit var finishIntent: Intent
  
  finishIntent = Intent()
  
  finishIntent.putExtra(&quot;list&quot;, ArrayList(modifiedMemes))
  setResult(RESULT_OK, finishIntent)
  </code></pre>
  <p>and try to receive it in A:</p>
  <pre><code>public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
      super.onActivityResult(requestCode, resultCode, intent)
  
      if(requestCode == 777 &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null) {
  
          if(data.hasExtra(&quot;list&quot;)) {
              val updatedMemes = intent.getParcelableArrayListExtra&lt;Memes&gt;(&quot;list&quot;) as ArrayList&lt;Memes&gt;
          }
      }
  }
  </code></pre>
  <p>so I set it exactly the same way for sending and recieving from a to b but I get the error:</p>
  <pre><code>kotlin.TypeCastException: null cannot be cast to non-null
  </code></pre>
  <p>on</p>
  <pre><code>val updatedMemes = intent.getParcelableArrayListExtra&lt;Memes&gt;(&quot;list&quot;) as ArrayList&lt;Memes&gt;
  </code></pre>
  <p>What is wrong here? Does google actually care that android is a giant disfunctional pile of dog crap?</p>