Android的四种重要组件

本文详细介绍了Android应用中的核心组件,包括Activity、服务、内容提供者和广播接收器的功能与实现方式,以及它们在应用程序开发中的重要作用。

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
19104551_hCSp.pngKnown Direct Subclasses    

AppWidgetProvider       ,       DeviceAdminReceiver            

AppWidgetProviderA convenience class to aid in implementing an AppWidget provider. 
DeviceAdminReceiverBase 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广播给其他的应用程序。

转载于:https://my.oschina.net/u/435726/blog/79525

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值