title: Android: Receive a SMS from a defined number in an invisible way
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1741628/can-we-delete-an-sms-in-android-before-it-reaches-the-inbox">Can we delete an SMS in Android before it reaches the inbox?</a>  </p>
  </blockquote>
  
  
  
  <p>In my android application that is now working fine, I am sending custom SMS from a user to other one.</p>
  
  <p>Once I detect the SMS come from my application, I do my stuff with the message and everything work fine.</p>
  
  <p>But now, I do not want the SMS application to detect this message as it is totally useless for the user.</p>
  
  <p>So what I would like to do:
  As soon I receive it, I get the text and avoid the system to get it ( or at least stop the notification for this message)</p>
  
  <p>Any Idea on how to do?</p>
  
  <p>Here is my current code:</p>
  
  <p>(EDIT: Sorry for the formatting, I cannot understand how that work!)</p>
  
  <pre><code>public class SmsReceiver extends BroadcastReceiver {
  
  @Override
  
  public void onReceive(Context context, Intent intent) {
  
  // ---get the SMS message passed in---
  
  Bundle bundle = intent.getExtras();
  
  SmsMessage[] msgs = null;
  
  String str = "";
  
   if (bundle != null) {
  
  // ---retrieve the SMS message received---
  
  Object[] pdus = (Object[]) bundle.get("pdus");
  
  msgs = new SmsMessage[pdus.length];
  
  String number = "";
  
  String body = "";
  
  for (int i = 0; i &lt; msgs.length; i++) {
      msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
      number = msgs[i].getOriginatingAddress();
      body = msgs[i].getMessageBody().toString();
      str += "SMS from " + number;
      str += " :";
      str += body;
      str += "\n";
     }
  If(detectIfSmsComeFromMyApplication)
  // DELETE MESSAGE AND AVOID BROADCAST.
  // MAKE IT INVISIBLE TO USER
  </code></pre>
  
  <p>}</p>
  
  <p>}
  }</p>