title: Error-proof way of starting SMS intent in Android
body: <p>In my Android application, I use the following code to start the messaging app and fill in a default text for a text message:</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse("sms:"+USERS_PHONE_NUMBER));
  intent.putExtra("sms_body", "DUMMY TEXT");
  startActivity(intent);
  </code></pre>
  
  <p>This works in most cases. But unfortunately, on some devices I get the following error message:</p>
  
  <pre><code>android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=sms:+XXXXXXXXXX (has extras) }
  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1510)
  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
  at android.app.Activity.startActivityForResult(Activity.java:3131)
  at android.app.Activity.startActivity(Activity.java:3237)
  </code></pre>
  
  <p>Obviously, the intent that I created cannot be handled.</p>
  
  <ul>
  <li><strong>Is there any mistake in my SMS intent code?</strong></li>
  <li><strong>How can I prevent the application from crashing if the intent cannot be handled?</strong></li>
  </ul>
  
  <p>Should I use PackageManager.queryIntentActivities() or is there another way of solving this problem?</p>
  
  <p>Thanks in advance!</p>