BroadcastReceiver与Service组件的基本应用场景

Android's generic broadcast receiver and service components allow developers to create a wide variety of efficient background operations, including things that were never originally considered. In Android 1.0 they were used to implement nearly all of the background behavior that the built-in and proprietary Google apps provided:

Android中的Broadcast Receiver与Service组件可用于开发一系列的后台操作。如在Android1.0,它们被用于实现几乎所有的内置后台行为:

  • Music playback runs in a service to allow it to continue operating after the user leaves the music application.
  • 当用户离开音乐应用时,Music playback以Service运行;
  • The alarm clock schedules a broadcast receiver with the alarm manager, to go off at the next set alarm time.
  • 闹钟应用使用闹钟管理调度了一个Broadcast receiver,直到下一次设置闹钟时间;
  • The calendar application likewise schedules an alarm to display or update its notification at the appropriate time for the next calendar event.
  • 日历应用同样调度一个闹钟以便在下次日历任务时来显示或更新提示;
  • Background file download is implemented a service that runs when there are any downloads to process.
  • 当后台文件正在下载时它以Service实现;
  • The e-mail application schedules an alarm to wake up a service at regular intervals that looks for and retrieves any new mail.
  • 邮件应用调度一个闹钟以便每隔一定时间检索和获取新邮件;
  • The Google applications maintain a service to receive push notifications from the network; it in turn sends broadcasts to individual apps when it is told that they need to do things like synchronize contacts.

  • Google应用维持一个Service来从网络中获取推送服务;

As the platform has evolved, these same basic components have been used to implement many of the major new developer features:

随着平台的演化,这些基本的组件也被用于实现很多新的开发特性:

  • Input methods are implemented by developers as a Service component that Android manages and works with to display as the current IME.
  • 输入法也作为Service服务组件实现以便Android管理和使用当前IME.
  • Application widgets are broadcast receivers that Android sends broadcasts to when it needs to interact with them. This allows app widgets to be quite lightweight, by not needing their application's process remain running.
  • 应用widgets是一项broadcast receiver
  • Accessibility features are implemented as services that Android keeps running while in use and sends appropriate information to about user interactions.
  • 可访问性以Service实现;
  • Sync adapters introduced in Android 2.0 are services that are run in the background when a particular data sync needs to be performed.
  • 当一些特殊的数据同步需要进行时,Sync adapters以Service运行于后台,
  • Live wallpapers are a service started by Android when selected by the user.
  • 活动壁纸以Service运行于后台。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值