title: SMS Receiver for AND API 19 and higher
body: <p>My job is to create SMS APP to hide selected numbers so that from falling further into default SMS app, this task is simple API for AND &lt;19 using this code.</p>
  
  <pre><code>public class SMSReceiver extends BroadcastReceiver {
  public static String TAG = "SMSReceiver";
  ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_MUSIC, 100);
  
  public SMSReceiver() {
  }
  
  @Override
  public void onReceive(Context context, Intent intent) {
      SMS_Throttle.VytvorDatabazi(context);
      String act = intent.getAction();
      Log.d(TAG, act);
      if (Dtb.HodnotaZNastaveniINT(ENastaveni.START_SKRYTE_SLUZBY, 1) == 1) {
          Bundle bundle = intent.getExtras();
          SmsMessage[] msgs = null;
          boolean isAbort = false;
          if (bundle != null) {
              Object[] pdus = (Object[]) bundle.get("pdus");
              msgs = new SmsMessage[pdus.length];
              String lst[][] = SMS_Throttle.getTlfCisla(context);
              String[] l = new String[lst.length];
              for (int j = 0; j &lt; lst.length; j++)
                  l[j] = lst[j][0];
              for (int i = 0; i &lt; msgs.length; i++) {
                  msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                  for (int j = 0; j &lt; l.length; j++) {
                      if (msgs[i].getOriginatingAddress().endsWith(l[j])) {
                          if (Dtb.HodnotaZNastaveniINT(ENastaveni.PRISLA_AKTIVITA, 0) == 1) {
                              tg.startTone(ToneGenerator.TONE_DTMF_5, 30);
                              Toast.makeText(context, msgs[i].getMessageBody(), Toast.LENGTH_LONG).show();
                          }
                          isAbort = true;
                          Dtb.UlozActivitu(l[j], msgs[i].getMessageBody(), EKomunType.RECEIVE_SMS);
                      }
                  }
              }
          }
          if (isAbort) {
              abortBroadcast();
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Important:</p>
  
  <p>Earlier versions of the API perfect shot abortBroadcast (). Thus, if the sender's number is listed in my list see the condition if (msg [i] .getOriginatingAddress (). EndsWith (l [i])) {then the SMS will be saved in my database and do not fall into default app for text messaging.</p>
  
  <p>If the number is not listed in my list, then into my database to store MUST but you must fall into default messaging app.</p>
  
  <p>Problem arose in API> = 19 where the abortbroadcast not work at all and moreover were removed right at the possibility of deletion of selected SMS from default SMS app.</p>
  
  <p>Advise someone how to solve the problem when you need to use my SMS receiver while the default? I've already read through almost everything <a href="http://android-developers.blogspot.cz/2013/10/getting-your-sms-apps-ready-for-kitkat.html" rel="nofollow">http://android-developers.blogspot.cz/2013/10/getting-your-sms-apps-ready-for-kitkat.html</a> but also many posts on stackoverflow but I never thought to address this encountered.</p>
  
  <p>Thanks for every idea</p>