Android 如何 截获拨号

用户在系统的拨号应用中输入完号码并且按拨号键后,还没真正拨出去前,我想作一些操作。比如修改号码或者检查权限。


       觉得系统的拨号动作应该还是发送一个intent,理论上是可以截获的。 终于,在开源工程sipUA中看到了方法。如下:

       首先,仔细看看API中关于intent.ACTION_NEW_OUTGOING_CALL的描述。写得很多很详细,节选一部分“You must hold the PROCESS_OUTGOING_CALLS permission to receive this Intent.This is a protected intent that can only be sent by the system”。

       系统拨号动作其实就是发送了一个包含这样一个intent的Broadcast Action。我们可以写个receiver来获得此intent. 如sipUA中:

java代码:
<receiver android:name=".ui.Caller">         <intent-filter android:priority="-1">          <action android:name="android.intent.action.NEW_OUTGOING_CALL" />         </intent-filter>     </receiver>

       需要注意的是 android:priority=”-1″  为什么截获这个intent需要这样设置,可以参考API中的说明。当然还要注意加上

java代码:

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>



原文出外: http://www.eoeandroid.com/thread-100615-1-1.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值