title: Android SMS Sending failed,Unable to find out the error
body: <p>Gives An error :"SMS failed,try again later in exception code".
  LOG file contains:"01-02 12:00:32.934: W/System.err(9560):  at dalvik.system.NativeStart.main(Native Method)  "
  Can any one tell me why the try statement is not working?</p>
  
  <pre><code>import android.os.Bundle;
  import android.app.Activity;
  import android.telephony.SmsManager;
  import android.util.Log;
   import android.view.Menu;
    import android.view.View;
    import android.widget.Button;
   import android.widget.EditText;
    import android.widget.Toast;
   public class MainActivity extends Activity {
  
    Button sendBtn;
   EditText txtphoneNo;
      EditText txtMessage;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Log.d(msg, "The onCreate() event");
      sendBtn = (Button) findViewById(R.id.btnSendSMS);
      txtphoneNo = (EditText) findViewById(R.id.editTextPhoneNo);
      txtMessage = (EditText) findViewById(R.id.editTextSMS);
  
      sendBtn.setOnClickListener(new View.OnClickListener() {
         public void onClick(View view) {
            sendSMSMessage();
         }
      });
  }
  protected void sendSMSMessage() {
      Log.i("Send SMS", "");
  
      String phoneNo = txtphoneNo.getText().toString();
      String message = txtMessage.getText().toString();
  
      try {
         SmsManager smsManager = SmsManager.getDefault();
         smsManager.sendTextMessage(phoneNo, null, message, null, null);
         Toast.makeText(getApplicationContext(), "SMS sent.",
         Toast.LENGTH_LONG).show();
      } catch (Exception e) {
         Toast.makeText(getApplicationContext(),
         "SMS faild, please try again.",
         Toast.LENGTH_LONG).show();
         e.printStackTrace();
      }
   }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  
  
   }
  </code></pre>