SMS Received in my SMS app and in Hangouts, although I call abortBroadcast()

旧城冷巷雨未停 提交于 2019-11-30 07:38:19

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).

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!