Android的四种重要组件

原创
2012/09/20 16:20
阅读数 164

Activity:

          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.

Services:

          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.

Content Providers:

           Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process.

BroadCast Recevicer:

 extends Object

java.lang.Object
   ↳ android.content.BroadcastReceiver
Known Direct Subclasses    

AppWidgetProvider       ,       DeviceAdminReceiver            

AppWidgetProvider A convenience class to aid in implementing an AppWidget provider. 
DeviceAdminReceiver Base class for implementing a device administration component. 

BroadCast Recevicer:接受一种或者多种Intent作触发事件,接受相关消息,做一些简单处理,转换成一条Notification,统一了Android的事件广播模型。可以使用BroadcastReceiver来让应用对外一个外部的事件作出响应。Broadcast Receiver通过NotificationManager来通知用户这些事情发生了,BroadcastReceiver注册的有两种方式,一种是可以在AndroidManifest.xml中注册,另一种可以在运行时的代码中使用Context.registerReceiver()进行注册。用户还可以通过Context.sendBroadcast()将他们自己的intent broadcasts广播给其他的应用程序。

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部