Android: what is the difference between Bundle Vs java.util collections like HashMap

前端 未结 2 1263
时光取名叫无心
时光取名叫无心 2020-12-17 16:22

What is the difference between Bundle Vs java.util collections like HashMap?

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 17:15

    One difference I can see easily is that a Bundle allows you to put int, boolean, etc., into it while a HashMap seems to require you to convert them to/from objects.

    A more important difference is that with a Bundle, every object it contains is parcelable. This allows Bundles to be used as service parameters and to be attached to intents / passed into activities.

提交回复
热议问题