android - 广播接收器中接收调用的优先级

标签 android broadcastreceiver

我的目的是制作一个在接到调用时执行操作的广播接收器。是否有可能比自动调用接收 SO 具有更高的优先级?

我已尝试分配优先级 2147483647,我认为这是最好的,但仍然让我在接收器结束之前尝试调用。

<!-- Receiver de llamadas -->
<receiver android:name=".PhoneCall">
    <intent-filter android:priority="2147483647">
        <action android:name="android.intent.action.PHONE_STATE"/>   
    </intent-filter>
</receiver>

最佳答案

此链接回答我:

http://developer.android.com/reference/android/content/BroadcastReceiver.html

可以接收两大类广播:

  • 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.

像 PHONE_STATE 这样的广播是“正常广播”。据我了解,不可能优先安排我的广播。有人想到什么办法吗?

关于android - 广播接收器中接收调用的优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14921144/

相关文章:

java - 如何从Android使用谷歌应用程序引擎查询实体?

java - 从 Java 调用 Javascript - Android

android - 有没有办法在eclipse中自动化模拟器android

android - 将数据从广播接收器传递到 Activity

未调用 Android 服务

android - LocalBroadcastManager 不会将消息从服​​务发送到 Activity

android - BroadcastReceiver 不保存局部变量

android - dataSnapshot 有对象,但 getValue() 将返回 null

android - 正确动画删除 ListView 中的行?

android - 如何仅向 URI 的创建者授予权限