开发者

What needs to be explicity bundled

When bundling an object for later retrieval do I have开发者_运维技巧 to bundle objects within those objects?

For example, if I have an object that represents a player in a card game and within that I instantiate an object that represents the player's hand, do I have save the inner object to the bundle or is that automatically included with the outer one?


You cannot bundle any old Object, it has to be a String or a primitive such as boolean, integer, 'byte' or an array of these simple things. In this case yes, the contents of a String[] array are saved with the Bundle.

For more complex structures you can use implement the Parcelable in your object class, but it will be up to you to make sure the object saves all necessary information to it's Parcel and restores it.


java.ui.Serializable is something worth checking. It pretty much automates bundling class and its member variables as long as your class and all required members implement Serializable interface too.

http://www.tutorialspoint.com/java/java_serialization.htm

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜