Today we’ll discuss and implement Android BroadcastReceiver that is a very important component of Android Framework.
今天,我们将讨论和实现Android BroadcastReceiver,它是Android Framework的非常重要的组成部分。
Android BroadcastReceiver (Android BroadcastReceiver)
Android BroadcastReceiver is a dormant component of android that listens to system-wide broadcast events or intents.
Android BroadcastReceiver是android的Hibernate组件,它侦听系统范围的广播事件或Intent 。
When any of these events occur it brings the application into action by either creating a status bar notification or performing a task.
这些事件中的任何一个发生时,它都会通过创建状态栏通知或执行任务来使应用程序生效。
Unlike activities, android BroadcastReceiver
doesn’t contain any user interface. Broadcast receiver is generally implemented to delegate the tasks to services depending on the type of intent data that’s received.
与活动不同,Android BroadcastReceiver
不包含任何用户界面。 广播接收器通常实现为根据接收到的意图数据的类型将任务委托给服务。
Following are some of the important system wide generated intents.
以下是一些在系统范围内产生的重要意图。
- android.intent.action.BATTERY_LOW : Indicates low battery condition on the device. android.intent.action.BATTERY_LOW :指示设备的电池电量不足。
- android.intent.action.BOOT_COMPLETED : This is broadcast once, after the system has finished booting android.intent.action.BOOT_COMPLETED :系统完成启动后,将广播一次
- android.intent.action.CALL : To perform a call to someone specified by the data android.intent.action.CALL :对数据指定的某人执行呼叫
- android.intent.action.DATE_CHANGED : The date has changed android.intent.action.DATE_CHANGED :日期已更改
- android.intent.action.REBOOT : Have the device reboot android.intent.action.REBOOT :重启设备
- android.net.conn.CONNECTIVITY_CHANGE : The mobile network or wifi connection is changed(or reset) android.net.conn.CONNECTIVITY_CHANGE :移动网络或wifi连接已更改(或重置)
Android中的广播接收器 (Broadcast Receiver in Android)
To set up a Broadcast Receiver in android application