在不同的Android活动之间交换数据或对象的正确方法是什么?
欢迎屏幕< - >主屏幕< - >启动例程< - >处理数据< - >设置
在Android应用中有多个活动是正常/建议的吗?在我看来,在应用程序中使用这种数据交换模型有些奇怪
Is it normal/recommended to have more than one activity in Android app?
Normal? Yes. Recommended? That depends on the app.
in my opinion, it's somehow strange to have this model of data exchange inside application
What do you do with Web apps? Well, you keep your model in a central spot (server) and you pass small bits of context data (URL parameters) in links between major units of UI (pages).
What do you do with desktop apps? Well, you keep your model in a central spot (database) and you pass small bits of context data (e.g., constructor parameters) in links between major units of UI (windows).
你如何处理Android应用程序?好吧,您将模型保存在中心位置(数据库ContentProvider等),并Intent在主要UI(活动)单元之间的链接中传递一小部分上下文数据(附加内容).
Android开发者页面上有一个概述:
http://developer.android.com/guide/appendix/faq/framework.html#3
总结一下,它取决于您要传递的数据类型.但一般来说,如果可能的话,我会选择Intents,因为它们很快并且为此而构建.
下面是一个示例,说明如何使用Intents在活动之间传递数据.
| 归档时间: |
|
| 查看次数: |
8421 次 |
| 最近记录: |