Bundle vs. Parcel vs. Message

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Bundle vs. Parcel vs. Message

Postby plusminus » Sun Jan 13, 2008 2:12 pm

Taken from the GoogleGroups...
Thought this might be of interest for some others and before the topic drowns in the GGroups I decided to post it here:

What is the difference between a Bundle and a Parcel and a Message?
What are the interactions between each. A detailed explanation would
go a long way to explaining the whole of the android.os package for


A Bundle is functionally equivalent to a standard Map. The reason we didn't
just use a Map is because in the contexts where Bundle is used, the only
things that are legal to put into it are primitives like Strings, ints, and
so on. Because the standard Map API lets you insert arbitrary Objects, this
would allow developers to put data into the Map that the system can't
actually support, which would lead to weird, non-intuitive application
errors. Bundle was created to replace Map with a typesafe container that
makes it explicitly clear that it only supports primitives.

A Parcel is similar to a Bundle, but is more sophisticated and can support
more complex serialization of classes. Applications can implement the
Parcelable interface to define application-specific classes that can be
passed around, particularly when using Services. Parcelables can be more
sophisticated than Bundles, but this comes at a cost of significantly higher

Bundle and Parcel are both data serialization mechanisms, and for the most
part both are used when application code is passing data across processes.
However, because Parcel is much higher overhead that Bundle, Bundles are
used in the more common places like the onCreate method, where overhead must
be as low as possible. Parcels are most commonly used to allow applications
to define Services with logical APIs that can use application-meaningful
classes as method arguments and return values. If we required Bundle there,
it would result in really clunky APIs. You should in general still keep
your Service APIs as simple as possible, because primitives will serialize
more efficiently than custom Parcelable classes.

The Message class is very different. A Message is really just a way for an
application to send messages between threads, and is not related to data
serialization. Since accesses to Views must be single-threaded, the
MessageHandler and related Message classes are commonly used to make it
easier to pass messages between threads.

Hope that helps!

- Dan

Image | Android Development Community / Tutorials
User avatar
Site Admin
Site Admin
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany


Re: Bundle vs. Parcel vs. Message

Postby Shaista » Thu Mar 29, 2012 8:11 pm

Very Interesting point. Happy to see a good summary.
Is it possible to add more links on this for further or rather a detail description.

Thanks again.
Posts: 4
Joined: Wed Oct 20, 2010 9:02 pm


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests