活动之间共享域对象

编程入门 行业动态 更新时间:2024-10-23 18:35:23
本文介绍了活动之间共享域对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写我的应用程序逻辑域对象(以使多用户界面和移植到其他平台),和我现在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.

您需要在指定您的自定义类的<应用> 标签的的Andr​​oidManifest.xml 文件。

You'll need to specify your custom class in the <application> tag of your AndroidManifest.xml file.

更多推荐

活动之间共享域对象

本文发布于:2023-08-01 12:28:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268336.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!