I have written my application logic in domain objects (to enable multiple user interfaces and porting to other platforms), and am now lookng at implementing Activities for the user interface.
Considering that each activity needs to serialise its state, what is the best way to ensure my domain objects are only serialised once?
If you’re talking about Serialising object to share them between Activities you should create your own subclass of
Applicationand store your shared state in there. A singleApplicationobject is shared by all the Activities in your app which makes it the perfect place to store non-persistent state. You can get to theApplicationby calling thegetApplication() methodon yourActivityorService.You’ll need to specify your custom class in the
<application>tag of yourAndroidManifest.xmlfile.