开发者

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;
    } 
}


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜