Isn’t android’s Bundle functionally equivalent with a Map?

Technology CommunityCategory: AndroidIsn’t android’s Bundle functionally equivalent with a Map?
VietMX Staff asked 4 years ago

First, a Map does not necessarily have String keys.

Second, while a Map can hold arbitrary objects, it cannot do so in a typesafe fashion. IOW, if you want the Map to hold strings, integers, and so forth, you will need to keep casting the results of get() calls, because your Map would have to be Map<String, Object>.

Third, Bundle implements Parcelable, which is very important for Android IPC. Map is an interface and does not extend Parcelable. This allows Bundles to be used as service parameters and to be attached to intents / passed into activities.

Please Disable AdBlock Plus and Refresh Website