我写我的应用程序逻辑域对象(以使多用户界面和移植到其他平台),和我现在lookng在执行活动的用户界面。
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?
推荐答案如果你谈论的是序列化的对象活动之间的共享,你应该创建自己的 应用程序 并存储在那里,你的共享状态。一个应用程序对象是所有的活动在您的应用程序,这使得它存储的非持久的状态下完美的地方共享。你可以在应用程序通过调用的 getApplication()方法 你的活动或服务。
If you're talking about Serialising object to share them between Activities you should create your own subclass of Application and store your shared state in there. A single Application object is shared by all the Activities in your app which makes it the perfect place to store non-persistent state. You can get to the Application by calling the getApplication() method on your Activity or Service.
您需要在指定您的自定义类的<应用> 标签的的AndroidManifest.xml 文件。
You'll need to specify your custom class in the <application> tag of your AndroidManifest.xml file.
更多推荐
活动之间共享域对象
发布评论