如何中止广播通知? (对于非有序广播)

时间:2013-04-24 12:51:49

标签: android broadcastreceiver android-manifest broadcast

我的应用程序处理Cell Broadcast消息,这是一种无序广播。 我希望我的应用程序接收此广播并终止CB消息的消息通知。

我发现可以通过使用带有优先级标记的意图过滤器来抑制短信通知,如下所示

<receiver android:name="com.example.sis.xxyyReceiver" >
      <intent-filter android:priority="999">
         <action android:name="android.provider.Telephony.SMS_RECEIVED" >
         </action>
      </intent-filter>
</receiver>

所以我试图用这样的CB消息做同样的事情

<intent-filter android:priority="100">
     <action android:name="android.provider.Telephony.CB_RECEIVED" >
     </action>
</intent-filter>

但它没有用,日志猫看起来如下

enter image description here

从我的研究和下面的评论中,我了解到非有序广播不能被中止,所以我想做的就是抑制CB消息产生的通知(即CB_SMS警报和振动)。

任何人都可以帮我解决非有序广播通知吗?

2 个答案:

答案 0 :(得分:7)

您不能中止常规广播。为他们注册BraodcastReceiver的每个人都会得到他们。

答案 1 :(得分:0)

或者,您可以调低音量?

或者只是模仿蓝牙耳机挂钩自动拨打电话(默默地)?

Intent i = new Intent(Intent.ACTION_MEDIA_BUTTON);
                i.putExtra(Intent.EXTRA_KEY_EVENT,
                        new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK));
                context.sendOrderedBroadcast(i, "android.permission.CALL_PRIVILEGED");

                Intent o = new Intent(Intent.ACTION_MEDIA_BUTTON);
                o.putExtra(Intent.EXTRA_KEY_EVENT,
                        new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
                context.sendOrderedBroadcast(o, "android.permission.CALL_PRIVILEGED");
相关问题