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