I have mutable Map as private var optionsList: MutableMap<String, List<String>> = mutableMapOf()
and i need to send it to another activity , i used this :
val optionsIntent = Intent(this@MainActivity, OptionsActivity::class.java)
optionsIntent.putExtra(
"optionsLi",optionsList)
startActivity(optionsIntent)
And it gives me an error in putExtra
, but I can't find anything that is like putMap or something to use.
Use
private var optionsList: HashMap<String, List<String>> = hashMapOf()
Instead of
private var optionsList: MutableMap<String, List<String>> = mutableMapOf()
As HashMap implements the Serializable interface, which makes it easy to add it to an intent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With