title: Why do I get NullPointerException when sending an SMS on an HTC Desire, or what is SubmitPdu?
body: <p>So I get this stack trace:</p>
  
  <pre><code>java.lang.NullPointerException    
     at android.telephony.SmsMessage$SubmitPdu.&lt;init&gt;(SmsMessage.java:132)
     at android.telephony.SmsMessage.getSubmitPdu(SmsMessage.java:551)
     at android.telephony.SmsManager.sendTextMessage(SmsManager.java:228)
     at android.telephony.SmsManager.sendTextMessage(SmsManager.java:107)
     at com.emergency.button.SMSSender.safeSendSMS(SMSSender.java:91)
     at com.emergency.button.EmergencyActivity$EmergencyThread
         .sendSMS(EmergencyActivity.java:294)
     at com.emergency.button.EmergencyActivity$EmergencyThread
         .sendMessages(EmergencyActivity.java:386)
     at com.emergency.button.EmergencyActivity$EmergencyThread
         .run(EmergencyActivity.java:266)
  </code></pre>
  
  <p>And this is how I call sendTextMessage, I don't verify message length or phone number validity:</p>
  
  <pre><code>sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
  </code></pre>
  
  <p>This error seems to only occur on HTC Desire or HTC Wildfire with android version 2.2 or 2.21 so I dug up the android platform source (which is actually not as easy to do as I expected) and found:<br>
  <a href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=telephony/java/android/telephony/SmsMessage.java;h=0617dada43e6119ab009cc917f11e1284ff09580;hb=5c1207be90fdf296c1b83034b7c68915e1749284" rel="nofollow noreferrer">SmsMessage.java once upon a time</a> though this might not be relevant as I see some of the line numbers don't line up.<br>
  The <a href="http://code.google.com/p/emergencybutton/" rel="nofollow noreferrer">emergency button project</a> is open source so you can check the code out for reference. I should probably note that I can't test this myself, I don't have either phone model.</p>