I am deleting an SMS from the inbox but I want to know: How can I delete it before it reaches the inbox?
Step-1: Create your custom broadcast receiver to receive sms. write the logic to abort the broadst so that the message will not be available to your inbox
public class SMSReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
if(conditionMatches){
abortBroadcast();
}
}
}
Step-2 Register broadcast receiver in AndoridManifest and put android:priority value a large number
Thats It
How does the above code work
As SMS receiving broad cast is an ordered broadcast the receiver with high priority will receive first so your application receive first and after receiving you are aborting broadcast. So no other application can receive it. Hence the sms will not exist in inbox