title: Can't have my app programatically send SMS if user doesn't use stock SMS app as default
body: <p>I've read through the <a href="http://android-developers.blogspot.co.il/2013/10/getting-your-sms-apps-ready-for-kitkat.html" rel="nofollow noreferrer">this blog post</a> about the changes made to using sending and receiving SMS in your app.  I've also read through various discussions and answers on this site and others.  However, I'm still not entirely clear on how this all works today.  I use the following code to send an SMS in my app (used for some simple user verification):</p>
  
  <pre><code>                        SmsManager smsManager = SmsManager.getDefault();
                          smsManager.sendTextMessage(phoneNumber, null, "sms verification", null, null);
                          SMSReceiver smsReceiver = new SMSReceiver();
                          IntentFilter filter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
  </code></pre>
  
  <p>I have a BroadcastReceiver with the following onReceive method:</p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {
          if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
              Bundle bundle = intent.getExtras();
              if (bundle != null){
  
                  SmsMessage[] messages = Telephony.Sms.Intents.getMessagesFromIntent(intent);
                  for (int i = 0; i &lt; messages.length; i++) {
                      SmsMessage message = messages[i];
                      String phNum = message.getDisplayOriginatingAddress();
                      phNum = phNum.replaceAll("[^0-9]", "");
                      Log.i("SMSReceiver", "phone="+phNum);
                  }
              }
          }
      }
  </code></pre>
  
  <p>During development, this worked fine on my phone (LG G3 running 4.4.2).  However, when I distributed the app to a few friends, the app never made it out of the sending phase of the code.  He has his default app set to Hangouts, but the app was trying (unsuccessfully) to send this message through the stock Android SMS app.  The send kept failing and thus it never even made it to the BroadcastReceiver.</p>
  
  <p>I didn't think I had to be the default messaging app to make this work, but I'm thinking now that that might be the point of this.  Is there a way to have my app pass a message to the default messaging app of the phone and also receive it in the BroadcastReceiver? I apologize if this is obvious from the existing documentation, but I just don't get it and I'm looking for a better explanation for why this would work on my phone running KitKat (with the stock SMS app as my default), but not on my friend's phone who's running Lollipop and using Hangouts as the default. Thanks!</p>
  
  <p>Here's a screenshot showing that the phone is trying to send the message through the stock SMS app:</p>
  
  <p><img src="https://i.stack.imgur.com/Wt4CJ.jpg" alt="screenshot of friend&#39;s sms error"></p>