Android abortBroadcast does not stop sms from broadcasting

in my onReceive method I have this code:

if (from.equals(number)) {
    abortBroadcast();
    in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(in);
    Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
} else {
    Toast.makeText(context, "Not from needed number", Toast.LENGTH_SHORT).show();
}   

where number = "29853" are the numeric messages from which I want to catch and not save in the inbox.

This code works correctly - if the SMS is from the number on which the first Toast works, and it prints the contents of the message, if the SMS is not from the "Not from the right number" number. The problem is that abortBroadcast is not doing its job - the message from the number is still in the phone’s inbox, although the priority of the receiver is 1000:

<receiver android:name=".service_classes.MyReceiver">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED"
                android:priority="1000" />
    </intent-filter>
</receiver>

What is the problem - why does abortBroadcast not work?

+5
source share
4 answers

abortBroadcast() "", . "", .

+3

android:priority , .

 <intent-filter android:priority="9999999"> 

, , , . , .

+8

I used this a while ago and it worked, I could reject some messages for display, but now it does not work. I think android no longer allows the user to fully control the SMS_RECEIVED event.

0
source

All Articles