什么是BroadcastReceiver的,当我们使用它?当我们、使用它、BroadcastReceiver

2023-09-06 02:06:58 作者:壮士丶干了这碗大姨妈

有人告诉我的BroadcastReceiver 的概念。它的使用以及如何使用它。

anybody please tell me the concept of BroadcastReceiver. Its use and how to use it .

推荐答案

通过读取启动documentation.另外,从应用程序基础复制的:

Start by reading the documentation. Also, copying from Application Fundamentals:

广播接收器

一个广播接收机是响应一个部件的全系统   广播公告。许多   广播与起源   系统,例如,一个广播   宣布,该屏幕已经变成   关闭时,电池电量低,或图片   被抓获。应用程序还可以   发起广播 - 例如,来   让其他的应用程序知道一些   数据被下载到该设备   并且可用于它们的使用。   虽然广播接收机不   显示用户界面,它们可能   创建一个状态栏通知   提醒用户当广播事件   发生。更常见的是,虽然,一个   广播接收器只是一个门户   到其他组件并且旨在   做工作的一个非常少量。对于   例如,它可能会启动一个服务   来执行基于所述一些工作   事件。

A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Applications can also initiate broadcasts—for example, to let other applications know that some data has been downloaded to the device and is available for them to use. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just a "gateway" to other components and is intended to do a very minimal amount of work. For instance, it might initiate a service to perform some work based on the event.

一个广播接收机被实现为的子类   BroadcastReceiver的和每个广播   是作为一个Intent对象。对于   更多信息,请参阅   BroadcastReceiver的类。

A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object. For more information, see the BroadcastReceiver class.

最后,请阅读常规任务你如何利用BroadcastReceivers来监听消息并设置报警。

Finally, read in Common Tasks how you can utilize BroadcastReceivers to listen for messages and set alarms.