who know android Parcelable efficiency when used intent.putExtra()
I have a problem.
When I send a object' infomation to another activity by intent. I used the implement开发者_运维百科 parcelable Object or(serialization) or a key-value bundle that every the object's field.
Which way is best?
As per the discussion at http://groups.google.com/group/android-developers/browse_thread/thread/e97689f91d3b9005?fwc=2
Serializable is slow largely because it is super general and completely deals with backwards compatibility, object references, automatically saves fields for you (reflection is slooow), etc. Parcelable is fast because it does none of these things, and thus is only suitable for IPC and not persistent storage.
I think that its not a question of which is better. Passing the data thought a Bundle is useful when all you want is the data, a Parcelable is useful when you want to act on the data (i.e. call methods) because it allows for a full object reconstruction.
精彩评论