Convert Map to Bundle in android

前端 未结 7 2088
面向向阳花
面向向阳花 2020-12-29 17:58

Is there an easy way to convert a Map to a Bundle in android without explicit iteration?

Why?

Firebase returns a Map for Notification

7条回答
  •  生来不讨喜
    2020-12-29 18:41

    Neat Kotlin solution using spread operator will look like that:

    fun Map.toBundle(): Bundle = bundleOf(*this.toList().toTypedArray())
    

提交回复
热议问题