接收短信不通知短信、通知

由网友(放縱你的習慣)分享简介:我希望收到短信在我的应用程序,但我不希望我的Andr​​oid展现出关于该事件的通知。算法:I want to receive a sms in my app, but I don't want my Android to show a notification about that event. Algorithm...

我希望收到短信在我的应用程序,但我不希望我的Andr​​oid展现出关于该事件的通知。算法:

I want to receive a sms in my app, but I don't want my Android to show a notification about that event. Algorithm:

1)接收短信(这是确定)

1) Receive sms (it's ok)

2)如果这是一个短信特殊内容格式(我的应用程序) - 处理它与我的应用程序,并且不显示通知

2) If this is a sms with special content-format (for my app) - process it with my app and don't display a notification.

3)如果这是一个简单的信息 - 我不想处理它,所以通知必须显示

3) If this is a simple message - I don't want to process it, so a notification must be displayed.

我试图用一种有序的广播,但它并不能帮助。某处,我读了SMS_RECEIVE的广播没有有序的,但我看到一些应用程序,它可以接收短信不通知。

I tried to use an ordered broadcast, but it doesn't help. Somewhere I read that SMS_RECEIVE's broadcast is not ordered, but I saw some apps, which can receive SMS without notify.

有没有人能帮助我或者给我正确的方式来解决这个问题?

Does anyone can help me or show me the right way to solve this problem?

感谢。

UPD:调用abortBroadcast()的boradcast没有帮助

Upd.: calling abortBroadcast() in boradcast doesn't help

推荐答案

设置优先于你的意图过滤器 //在清单

set priority in your intent-filter // in manifest

<intent-filter android:priority="100">  /*your receiver get high priority*/

//广播接收器

// in broadcast receiver

 if (keyword_match)
      {
        // Stop it being passed to the main Messaging inbox
        abortBroadcast();
      }
阅读全文

相关推荐

最新文章