Android的 - 从循环停止NEW_OUTGOING_CALL事件? [英] Android - stopping NEW_OUTGOING_CALL events from looping?

查看:467
本文介绍了Android的 - 从循环停止NEW_OUTGOING_CALL事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个广播接收器 ACTION_NEW_OUTGOING_CALL 事件。

的onReceive()方法,我要送所提供的数字到一个新的 ListActivity ,其中用户到达从列表中选择各种新的目的地号码。

当用户从列表中选择一个新号码,我再开始在URI领域的新号码一个新的 ACTION_CALL 意图。可替代地,其结果可能是原始数

不管新的号码是,它必须立即拨打和不处理任何进一步的

我怎样才能让广播接收器知道这个结果数字不应该再次处理?


解决方案

我在我的广播接收器实施搭桥preFIX解决了这个。如果我的客户端应用程序要调用一些直接它只是$ P $调用ACTION_CALL意图之前ppends的preFIX。

如果所拨打的号码有(硬codeD)preFIX,在广播接收器剥离preFIX并允许呼叫正常进行

 公共无效的onReceive(上下文的背景下,意图意图)
{
    字符串行动= intent.getAction();
    如果(Intent.ACTION_NEW_OUTGOING_CALL.equals(动作)){
        串号= getResultData();
        如果(number.startsWith(BYPASS_ preFIX)){
             setResultData(number.substring(BYPASS_ preFIX.length()));
        }其他{
             //做额外的处理
        }
    }
}

这解决了一气呵成两个问题 - 不仅是这是否停止呼叫循环,这也给了我一个方式通过存储在他们的电话簿条目的preFIX绕过特定号码额外的处理。

I have a BroadcastReceiver catching ACTION_NEW_OUTGOING_CALL events.

In the onReceive() method I'm sending the supplied number to a new ListActivity, where the user gets to choose various new destination numbers from a list.

When the user selects a new number from the list I'm then starting a new ACTION_CALL intent with the new number in the URI field. Alternatively, the result might be the original number.

Whatever the new number is, it has to be dialled immediately and not processed any further.

How can I let the BroadcastReceiver know that this resulting number shouldn't be processed yet again?

解决方案

I resolved this by implementing a "Bypass Prefix" in my BroadcastReceiver. If my client app wants to call a number directly it simply prepends the prefix before invoking the ACTION_CALL Intent.

If the dialed number has the (hard coded) prefix, the BroadcastReceiver strips the prefix and allows the call to proceed as normal:

public void onReceive(Context context, Intent intent)
{
    String action = intent.getAction();
    if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {
        String number = getResultData();
        if (number.startsWith(BYPASS_PREFIX)) {
             setResultData(number.substring(BYPASS_PREFIX.length()));
        } else {
             // do additional processing
        }
    }
}

This solves two problems in one go - not only does this stop the call looping, it also gives me a way to bypass the additional processing for specific numbers by storing the prefix in their phone book entries.

这篇关于Android的 - 从循环停止NEW_OUTGOING_CALL事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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