Efficiency of Parcelable for inproc communication
I want to pass a huge object (e.g. Bitmap
) from one activity to another inside one process. If I put it into the Bundle
as Parcelable
, will Android rea开发者_StackOverflow社区lly serialize the object or pass it by reference?
Android uses a Parcelable object when it transfers the information from one process to another. In this case, it at first parse the object into primitives and then send them to a remote process. So as (usually) two activities of the same application is running in the same process, there is no need to parse the object. Here I found that in your case it will be created a weak reference to your object and it will be passed to the second activity. If you have activities in different processes (e.g. within different applications) then your object will be parsed and sent to the second process (and in this case it will be sent by values, I guess).
精彩评论