如何中止广播通知? (用于非有序广播) [英] How to abort broadcast notification? (for a non Ordered Broadcast)

查看:187
本文介绍了如何中止广播通知? (用于非有序广播)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序处理小区广播的消息,这是一种非有序的广播。 我想我的应用程序,以接收该广播和杀死CB消息的消息通知。

My application deals with Cell Broadcast messages, which is a non ordered broadcast. I want my application to receive this broadcast and kill the message notification of CB messages.

我发现,短信通知可以通过使用一个意图过滤器具有优先级标记pssed燮$ P $,如下图所示。

I've found out that SMS notification can be suppressed by using an intent filter with a priority tag as shown below

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

所以我试图用这样的小区信息做同样的

So I've tried to do the same with CB messages like this

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

但它没有工作,和日志猫看起来如下:

But it didn't work, and the log cat looks as follows

从我的研究,下面的评论,我已经了解到,非有序广播不能中止,因此,所有我想要做的是晚饭preSS的通知(即CB_SMS警报和振动)通过CB消息产生。

From my research and below comments, I've learned that non Ordered broadcasts cannot be aborted, So all I want to do is to suppress the notification (i.e CB_SMS alert and vibration) generated by CB message.

谁能帮我这个败非有序广播通知??

Can anyone help me with this aborting of non ordered broadcasts notification??

推荐答案

另外,你可以把音量调?

Alternatively, you could turn down the volume?

或者,也许只是模拟蓝牙耳机钩自动应答来电(默默)?

Or maybe just emulate the bluetooth headset hook to autoanswer the call (silently)?

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");

这篇关于如何中止广播通知? (用于非有序广播)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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