开发学院手机开发Android 开发 Android:BroadcastReceiver 阅读

Android:BroadcastReceiver

 2010-10-19 20:16:47 来源:WEB开发网   
核心提示:android.content.BroadcastReceier.public abstract classBroadcastReceiverextends ObjectClass OverviewBase class for code that will receive intents sent by sendBro

android.content.BroadcastReceier.

public abstract class

BroadcastReceiver

extends Object

Class Overview

Base class for code that will receive intents sent by sendBroadcast(). You can either dynamically register an instance of this class with Context.registerReceiver() or statically publish an implementation through the tag in your AndroidManifest.xml. Note: If registering a receiver in your Activity.onResume() implementation, you should unregister it in Activity.onPause(). (You won't receive intents when paused, and this will cut down on unnecessary system overhead). Do not unregister in Activity.onSaveInstanceState(), because this won't be called if the user moves back in the history stack.

作用:接收由sendBroadcast()发送的Intent。

There are two major classes of broadcasts that can be received:

Normal broadcasts (sent with Context.sendBroadcast) are completely asynchronous. All receivers of the broadcast are run in an undefined order, often at the same time. This is more efficient, but means that receivers cannot use the result or abort APIs included here.

Ordered broadcasts (sent with Context.sendOrderedBroadcast) are delivered to one receiver at a time. As each receiver executes in turn, it can propagate a result to the next receiver, or it can completely abort the broadcast so that it won't be passed to other receivers. The order receivers run in can be controlled with the android:priority attribute of the matching intent-filter; receivers with the same priority will be run in an arbitrary order.

这里:Normal broadcasts是不按顺序发送广播消息的。而Ordered broadcasts是一次只发送一个广播消息给一个接收者。

Even in the case of normal broadcasts, the system may in some situations revert to 恢复delivering the broadcast one receiver at a time. In particular, for receivers that may require the creation of a process, only one will be run at a

1 2 3 4 5 6  下一页

Tags:Android BroadcastReceiver

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
更多精彩
    赞助商链接

    热点阅读
      焦点图片
        最新推荐
          精彩阅读