title: Force app to wait to send a new text message
body: <p>I've got a pretty simple app I'm trying to make. What I want to do is have an app that can send multiple texts to 1 or more recipients. I have accomplished this, but it doesn't seem to send the full number of texts.</p>
  
  <p>I assume the problem is that the texts are being sent to rapidly. I'm trying to just make the program wait a second, but when I just type in "Thread.sleep(1000);" I get an error saying there is an unhandled exception in Eclipse. Is there a way around this? Do I really need to do a try/catch for these few lines of code? If I do need a try/catch, what's the best way to write it for this app?</p>
  
  <p>Also, as a note I be allowing the sleep time to be customized in a later version, so please keep that in mind with your responses.</p>
  
  <pre><code>Integer i = 0;
  while (i &lt; numTextSend)
  {
          sms.sendTextMessage(number, null, message, null, null);
          Thread.sleep(1000);
              i++;
  }
  </code></pre>
  
  <p>[EDIT] Updated Code:</p>
  
  <pre><code>final Button confirm = (Button) findViewById(R.id.confirm);
  confirm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
          //Grab values from UI
              String number = String.valueOf(mNumber.getText().toString());
              Integer numTextSend = Integer.parseInt(mNumTextSend.getText().toString());
              String message = String.valueOf(mMessage.getText().toString());
  
              //Send SMS message(s)
              SmsManager sms = SmsManager.getDefault();
              Integer i = 0;
              while (i &lt; numTextSend)
              {
                  sms.sendTextMessage(number, null, message, null, null);
                  //Make App wait 1 second
                  i++;
              }
         }
   });
  </code></pre>