I was trying to block all the incoming sms in my android device.
This is the code i was using-
public class SmsReceiver extends BroadcastReceiver {
/**
You cannot block incoming SMS since API 19 (KitKat), unless your app is the default messaging app, and even then you can only stop them from being saved to the SMS Provider.
The SMS_RECEIVED
broadcast can no longer be aborted, so any app listening for it will still get it. Furthermore, the default app receives a different broadcast anyway - SMS_DELIVER
- which is not received by any other app, and cannot be intercepted.
If your app is the default SMS app, it is responsible for writing the incoming messages to the SMS Provider, so if you don't want them saved there, just don't write them. However, this will have no effect on the SMS_RECEIVED
broadcast, which will still be delivered to any app registered for it, though those apps won't be able to write them to the Provider.
The following blog page discusses the SMS API changes, and includes details on the requirements for an app to act as the default messaging app. Do note, though, that the default app is responsible for many, many things - including MMS, as well - and writing a full-blown messaging client is not a trivial task.
Getting Your SMS Apps Ready for KitKat