在一个广播接收器,以接收呼叫的优先 [英] priority in a broadcast receiver to receive calls

查看:93
本文介绍了在一个广播接收器,以接收呼叫的优先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意图是使广播接收器,接收呼叫时执行的操作。是否有可能有更多的优先级比自动呼叫接收SO?

我已经试过指定为2147483647的一个优先事项,我认为是最好的,但还是跳到了我的接收机年底前尝试呼叫。

 <! - 接收机去llamadas  - >
    <接收机器人:名称=。PhoneCall>
            <意图过滤器
                机器人:优先=2147483647>
                    <作用机器人:名称=android.intent.action.PHONE_STATE/>
            &所述; /意图滤光器>
        < /接收器>
 

解决方案

这个链接回答我:

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

有广播节目,可以接收两个主要的类:

  
      
  • 普通广播(带Context.sendBroadcast发送)是完全同步的。广播的所有接收机都处于未定义运行   顺序,常常在相同的时间。这是更有效的,但意味着   接收器不能使用的结果或中止包括这里的API。

  •   
  • 序广播(与Context.sendOrderedBroadcast发送)被输送到一个接收机的时间。由于每个接收器将执行   转,它可以传播的结果到下一个接收器,或它可以   完全中止该广播,以便它不会被传递到其他   接收器。订单接收器运行在可以与被控制   机器人:匹配意图过滤器的优先级属性;接收器   具有相同优先级可以为任意的顺序来运行。

  •   

广播像PHONE_STATE是正常播放。据我的理解是不可能的优先考虑我的广播。有谁想到什么办法?

my intention is to make a Broadcast receiver that performs actions when receiving a call. Is it possible that had more priority than the automatic call reception SO?.

I've tried assigning a priority of 2147483647 which I think is the best, but still jumps me to try the call before the end of my receiver.

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

解决方案

This link answer me:

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

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.

Broadcast like PHONE_STATE are "Normal broadcast". As far as I understand it is not possible to prioritize my broadcast. Does anyone think of any way?

这篇关于在一个广播接收器,以接收呼叫的优先的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆