开发者

Efficiency of Parcelable for inproc communication

开发者 https://www.devze.com 2023-01-19 19:12 出处:网络
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

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号