微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 广播接收器中接收呼叫的优先级

我的目的是制作一个广播接收器,在接收呼叫时执行动作.是否有可能比自动呼叫接收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这样的广播是“普通广播”.据我所知,不可能优先考虑我的广播.有没有人想到任何方式?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐