SMS Received in my SMS app and in Hangouts, althou

2019-02-05 08:44发布

I have an SMS blocker Android application developed myself which was working quite well capturing all the spams until recently Google updated its Hangouts app to work with SMSs.

The Problem: SMS is getting captured by both my app and hangouts! Even though the message is blocked by my app and stored in its private database, it is also present in the hangouts app and thus in the stock Messaging app at the same time.

Seems the abortBroadcast() isn't working any more. Everything was working perfectly before the Hangouts update.

I had also tried fiddling with android:priority but in vain.

2条回答
甜甜的少女心
2楼-- · 2019-02-05 08:57

Hangouts uses the maximum possible priority (999 per the Intent-Filter docs) and therefore you cannot abort it on <4.4 releases. On 4.4+, only the default SMS app (blog post with details) can receive SMS notifications - users would need to set your app as the default SMS app for your app to function correctly (although it should function as expected if that happens).

查看更多
迷人小祖宗
3楼-- · 2019-02-05 09:12

When you register receiver, set priority of filter to INTEGER.MAX_VALUE. Now abortBroadcast() will work;

    receiver = new HightPrioritySmsReceiver();
    IntentFilter filter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
    filter.setPriority(Integer.MAX_VALUE);
    registerReceiver(receiver, filter);
查看更多
登录 后发表回答