【问题标题】:NEW_OUTGOING_CALL not being called on Samsung Galaxy S三星 Galaxy S 上未调用 NEW_OUTGOING_CALL
【发布时间】:2011-07-14 16:25:20
【问题描述】:

试图拦截拨出电话,并有一个很好的解决方案

  • nexus 1 stock android 2.2
  • HTC 渴望 2.2
  • 摩托无视 2.1

但不是在运行 2.1 的三星 Galaxy S 上,有人看到了吗?

 <receiver  android:name="com.mypackge.OutGoingCallDetection" 
    android:exported="true"> 
 <intent-filter>   
  <action
    android:name="android.intent.action.NEW_OUTGOING_CALL"
    android:priority="0" /> 
</intent-filter> 
</receiver>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> 

更新:还添加了 PROCESS_OUTGOING_CALLS。

接收者:

public class OutGoingCallDetection extends BroadcastReceiver {

    private static final String TAG = "OutGoingCallDetection";


    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        Log.d(TAG, "onReceive, Action:" +intent.getAction());
    }
}

【问题讨论】:

    标签: android broadcastreceiver


    【解决方案1】:

    尝试按照 Google Dev 的建议整理清单:Manifest.xml

    像这样:

    <uses-permission />
    ...
    <receiver>
        <intent-filter> . . . </intent-filter>
        <meta-data />
    </receiver>
    

    部分设备解析 Manifest 的方式可能存在问题,可能无法正确注册接收方。

    编辑:从 ADT 16 开始,Lint 会告诉你你的权限在错误的地方,所以我假设这一定比以前认为的更严重

    干杯

    【讨论】:

      【解决方案2】:

      您需要添加用户权限:

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

      请参阅this blog post 作为如何设置和使用 NEW_OUTGOING_CALL 的示例。

      另请参阅 this blog post 以了解将 android:priority 设置为的内容。

      【讨论】:

      • 我有 PROCESS_OUTGOING_CALLS 权限(否则它不会在其他设备上工作)。阅读 Android 博客文章后,我使用优先级 0,但我将尝试优先级并回发。谢谢
      • 嗯很奇怪...我在很多三星 Galaxy S 设备上运行 NEW_OUTGOING_CALL 都没有问题,包括运行 Android 2.1 的设备没有任何问题。
      • 我的猜测是您的设备上安装了一些正在中止广播的东西,所以较低优先级的广播没有播放?所以,是的,优先考虑,看看你看到了什么。
      【解决方案3】:

      您是否尝试增加android:priority?假设最多 10000 个。

      我正在拦截传入的短信,增加android:priority 属性很有帮助

      【讨论】:

        【解决方案4】:

        我以编程方式创建了广播侦听器。它工作正常。供您参考。

        IntentFilter filter = new IntentFilter();
        filter.addAction("android.intent.action.NEW_OUTGOING_CALL");
        
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                Log.d(TAG, "onReceive, Action:" +intent.getAction());
            }
        };
        registerReceiver(receiver, filter);
        

        【讨论】:

          猜你喜欢
          • 2012-06-12
          • 2012-01-24
          • 2014-03-07
          • 2013-01-18
          • 2011-05-31
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多