title: How to block an incoming message in android?
body: <p>I am trying to develop an app in android which blocks an incoming sms. I have set the priority but its not blocking the incoming sms. I have used <code>this.abortBroadcast()</code> also but no result.</p>
  
  <pre><code>import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.telephony.gsm.SmsMessage;
  
  import android.widget.Toast;
  
  @SuppressWarnings("deprecation")
  public class SmsReceiver extends BroadcastReceiver
  {
  
  @Override
  public void onReceive(Context context, Intent intent) 
  {
  this.abortBroadcast();  
  
      Bundle bundle = intent.getExtras();        
      SmsMessage[] msgs = null;
      String str = "";
  
      if (bundle != null)
      {
  
  
          Object[] pdus = (Object[]) bundle.get("pdus");
          msgs = new SmsMessage[pdus.length];            
          for (int i=0; i&lt;msgs.length; i++){
              msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
              str += "SMS from " + msgs[i].getOriginatingAddress();                     
              str += " :";
              str += msgs[i].getMessageBody().toString();
              str += "\n";        
  
  }
  
  
  }
  }
  }
  </code></pre>
  
  <p>and the manifest file is like this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="BVB.EDU"
    android:versionCode="1"
    android:versionName="1.0"&gt;
  &lt;uses-sdk android:minSdkVersion="7" /&gt;
  
  &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
      &lt;activity android:name=".SMS"
                android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
  &lt;/application&gt;
  
  &lt;receiver android:name=".SMSReceiver"&gt;
       &lt;intent-filter android:priority="99999"&gt;
           &lt;action android:name="android.provider.Telephony.SMS_RECEIVED" /&gt;                  
       &lt;/intent-filter&gt;
   &lt;/receiver&gt;
  
  &lt;uses-permission android:name="android.permission.SEND_SMS"&gt;
  &lt;/uses-permission&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_SMS"&gt;
  &lt;/uses-permission&gt;
  
  &lt;/manifest&gt;
  </code></pre>