Android 开发之Broadcast receivers组件
2010-06-12 19:46:00 来源:WEB开发网Broadcast receivers只接受广播通知并做出反应的组件。广播通知往往来自系统,比如时区改变,语言改变。extends自BroadcastReceiver基类。
一个程序可以有好几个Broadcast receivers来接受它认为重要的通知。
Broadcast receivers没有用户界面,但是可以打开一个activity来对接受到的信息做出反应,或者利用NotificationManager来警告用户。Notifications可以用很多方法来引起用户的注意,一般是在状态栏显示一个图标,以便用户打开信息。
原文
Broadcast receiversA broadcast receiver is a component that does nothing but receive and react to broadcast announcements. Many broadcasts originate in system code — for example, announcements that the timezone has changed, that the battery is low, that a picture has been taken, or that the user changed a language preference. 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.
An application can have any number of broadcast receivers to respond to any announcements it considers important. All receivers extend the BroadcastReceiver base class.
Broadcast receivers do not display a user interface. However, they may start an activity in response to the information they receive, or they may use the NotificationManager to alert the user. Notifications can get the user’s attention in various ways — flashing the backlight, vibrating the device, playing a sound, and so on. They typically place a persistent icon in the status bar, which users can open to get the message.
更多精彩
赞助商链接