[转载]Android应用开发框架结构

[转载]Android应用开发框架结构 – bitfairyland – 博客园.

1.Android的应用开发与传统的Win32应用开发的区别
1)Android是一种松散的逻辑对象体
(Win32应用)
Android应用)
P1-P2-P3B2;P1-P2-P3-B3;P1-P2-P3-B2-B3;B1-V1;B1-V2…等等组新的应用集合,应用之间的逻辑讲究的是复用,是一个松散的集合,Android讲究的是这种的概念。
2)Android是事务先于实体而存在的,传统的Win32是一个实体逻辑通过消息组成事务,就存在实体可以做什么通过win平台消息告诉对方做什么。而Android的平台是告诉平台我想做什么,平台才去找对应的Activity,而并不一定能找到对应的逻辑体。
2.Android的应用开发主要包括四个部分
  • Activity
  • Intent
  • Service
  • Content Provier
1)Activity
Activity构成Android应用的基本单元,就是一个逻辑单元,也就是一个对象,或者说是一个类,处理一部分工作逻辑。主要完成2部分工作,接收平台传过来的消息或发生到平台消息消息,然后画图,得到给用户提供的交换界面,也就是形成所谓的手机窗体。
An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.(官方文档的定义)
2)Intent
Intent是Android应用平台的消息体,负责携带命令和数据传给新的Activity。
intent receiver是在AndroidManifest.xml注册的过滤器,启到广播给其它Activity的作用。
Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents. Intent messaging is a facility for late run-time binding between components in the same or different applications. The intent itself, an Intent object, is a passive data structure holding an abstract description of an operation to be performed — or, often in the case of broadcasts, a description of something that has happened and is being announced. There are separate mechanisms for delivering intents to each type of component:(官方文档的定义)
3)Service
Service是跑在Android平台的服务,提供类似于系统提醒消息的等

A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

A service can essentially take two forms:

Started
A service is “started” when an application component (such as an activity) starts it by calling startService(). Once started, a service can run in the background indefinitely, even if the component that started it is destroyed. Usually, a started service performs a single operation and does not return a result to the caller. For example, it might download or upload a file over the network. When the operation is done, the service should stop itself.
Bound
A service is “bound” when an application component binds to it by calling bindService(). A bound service offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with interprocess communication (IPC). A bound service runs only as long as another application component is bound to it. Multiple components can bind to the service at once, but when all of them unbind, the service is destroyed.
(官方文档的定义)
4)Content Provider
Content Provider是Android平台提供的一个数据共享的中间层
Content providers store and retrieve data and make it accessible to all applications. They’re the only way to share data across applications; there’s no common storage area that all Android packages can access(官方文档定义)
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏