Search code examples
javaandroid-intentarraylistkotlinmutablelist

Pass mutableList through intent


I have a mutableList.

var newList: MutableList<String> = mutableListOf()

How to pass newList through intent?

I tried this but not working.

 mIntent.putParcelableArrayListExtra("mFilePath", ArrayList(newList))

Error

Type inference failed. Expected type mismatch: required: java.util.ArrayList! found: kotlin.collections.ArrayList /* = java.util.ArrayList */


Solution

  • Was able to fix it.

      mIntent.putStringArrayListExtra("mFilePath", ArrayList(newList))