lawal
lawal

Reputation: 992

Sink or resend android received broadcast

I have an application that expects SMS messages in certain formats. If a SMS message meets specific criteria set out by my app, I want to prevent the re-broadcast of the SMS, otherwise allow it to proceed to other BroadcastReceiver (like the default SMS reader).

Does anyone know how this can be achieved?

public void onReceive(Context context, Intent intent) {

    String msg = processMessageFromIntent(intent);
    if(needed(msg)){
     //prevent propagation;
    } 
}

Upvotes: 1

Views: 470

Answers (2)

Jerome_B
Jerome_B

Reputation: 1097

This will only work if the intent has been sent with Context.sendOrderedBroadcast as per BroadcastReceiver.

So, you have to check with the broadcast you want to handle.

Upvotes: 0

lawal
lawal

Reputation: 992

The solution was to set a hight priority for the receiver and call abortBroadcast.

Upvotes: 1

Related Questions