Can we delete an SMS in Android before it reaches the inbox?

Yes.

Despite some negative reactions to this question, there are legitimate uses for SMS interception. For example: automating phone number verification, services which are provisioned via SMS (though generally this should be done with data SMS), or for applications which otherwise improve the user experience by processing specially-formatted messages in order to show them in a nice Android-specific UI.

As of Android 1.6, incoming SMS message broadcasts (android.provider.Telephony.SMS_RECEIVED) are delivered as an “ordered broadcast” — meaning that you can tell the system which components should receive the broadcast first.

If you define an android:priority attribute on your SMS-listening <intent-filter>, you will then receive the notification before the native SMS application.

At this point, you can cancel the broadcast, preventing it from being propagated to other apps.


Update (October 2013): When Android 4.4 arrives, it will make changes to the SMS APIs which may affect an app’s ability to influence SMS delivery.
Check out this Android Developers blog post for some more info:
http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html

Leave a Comment