Send SMS to a Recepient
<p>I am writing an app in which i am trying to <em>send SMS to a Recepient</em>, but whenever i do click on Send, getting message:- <strong>SMS faild, please try again later!</strong></p>

<p>Please see below screen shot, like you can see, here <em>i am trying to send message to Rahul</em>...</p>

<p>Manifest.xml:</p>

<pre><code> &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt;
</code></pre>

<p>Please check code below:</p>

<pre><code>       private TextView name;
private ListView list;
private Database db;
private Contact contact;
Button buttonSend;
EditText textSMS;

private Map&lt;String, AuthenticatorDescription&gt; map = new LinkedHashMap&lt;String, AuthenticatorDescription&gt;();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.editor);

    // bind GUI components
    this.name = (TextView) findViewById(R.id.editor_name);
    this.list = (ListView) findViewById(R.id.editor_list);

    // check if contact id is valid
    this.db = new Database(getContentResolver());
    int contactId = getIntent().getIntExtra(CONTACT_ID, NO_CONTACT_ID);
    this.contact = this.db.getContact(contactId);
    if (this.contact == null) {
        finish();
    }
    this.name.setText(this.contact.getName());

    // pre-load information about all account types
    AuthenticatorDescription[] authTypes = AccountManager.get(this).getAuthenticatorTypes();
    for (AuthenticatorDescription authDesc : authTypes) {
        this.map.put(authDesc.type, authDesc);
    }

    // bind list events
    this.list.setOnItemClickListener(this);
    this.list.setOnCreateContextMenuListener(this);

    // create the GUI
    updateView();



    saveGreeting = (ImageButton) findViewById(R.id.greeting);
    saveGreeting.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            customGreeting(v);
        }
    });
    buttonSend = (Button) findViewById(R.id.buttonSend);
    textSMS = (EditText) findViewById(R.id.editTextSMS);
    buttonSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

          String recepient = name.getText().toString();
          String sms = textSMS.getText().toString();

          try {
            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(recepient, null, sms, null, null);
            Toast.makeText(getApplicationContext(), "SMS Sent!",
                        Toast.LENGTH_LONG).show();
          } catch (Exception e) {
            Toast.makeText(getApplicationContext(),
                "SMS faild, please try again later!",
                Toast.LENGTH_LONG).show();
            e.printStackTrace();
          }

        }
    });
}
</code></pre>
