关键词:
android architecture patterns
题目好大,吓死自己了……
架构是自己一直都不了解的东西,只有好好地不断积累学习。
Android Architectural patterns
Architectural patterns for Mobile Application Development
Android Passive MVC: a Novel Architecture Model for Android Application Development
先看看别人是怎么做的:Fitness Android Application
从传统的 MVC 思想出发,参考: Android Architecture,这个博客里有三篇相关文章,介绍比较详细,要翻墙才能看,我下载放到 csdn 来了。
另一种思想是,把 MVC 变成 MVP,因为在 Android 使用 controller 一般是在 activity 或 fragment ,经常会把 View 层的东西混进来。
参考:Android application architecture - what is the suggested model?
The most popular architecture for software is:
Presentation Layer
Business Layer
Data Layer
存储 - 文件、数据库、配置;
缓存、更新、清理。
后台进程 - 是运行一个 services 还是新建一个 thread ?
UI进程管理
网络状态管理:添加了一个 receiver 监听网络状态变化,如有变化,发送一个全局事件,让感兴趣的主体来接收处理。
存储:简单来做,定时清理(一个月)而不是定量清理。
代码结构:
参考:App工程结构搭建
关于 Android 的进程:
- APP crash 之后,有可能主进程还在活动,如果有 Socket 连接的,Socket 连接也还可以会在。下次进来就可能不会再初始化了。
- APP crash 之后,可能直接重新进入上次 crash 的 activity ,当然,还会初始化自定义的 Application,但可能会不经过 android.intent.action.MAIN 声明的 activity ,此时要注意初始化的东西。