Send SMS to a selected contact [recepient] already stored in Phone Book
<p>I am making a app in which <strong>i am accessing phone book</strong> and <em>then select a contact to send a SMS to that particular recipient</em>, but whenever i am trying to send a SMS <em>getting error message</em> which i have given in Catch block of my code for in case of failure:" "<strong>SMS failed, please try again later!</strong>""</p>

<p><strong>Note:</strong> I have tried this on real device also, and getting same problem there...as well.</p>

<p><strong>Contact.java::</strong></p>

<pre><code>  public interface Contact {

public int getId();

public String getName();

public List&lt;RawContact&gt; getRawContacts();
</code></pre>

<p>}</p>

<p><strong>BirthdayEditor.java::</strong></p>

<pre><code>public class BirthdayEditor extends Activity implements OnItemClickListener {
private static final int CREATE_BIRTHDAY = 0;
private static final int EDIT_BIRTHDAY = 1;
private static final int DELETE_BIRTHDAY = 2;
private ImageButton saveGreeting;

public static final String CONTACT_ID = "contact_id";
private static final int NO_CONTACT_ID = Integer.MIN_VALUE;

private TextView name;
private ListView list;
private Database db;
private Contact contact;

ImageButton 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());
    final 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();               

    buttonSend = (ImageButton) findViewById(R.id.buttonSend);
    textSMS = (EditText) findViewById(R.id.editTextSMS);
    buttonSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

          String recepient = contact.getName().toString();
              Log.d(LOG_TAG, "onClick(" + recepient + ")");
          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>

<p><strong>Logcat  Says:</strong></p>

<pre><code>04-01 14:12:29.211: D/BirthdayEditor(950): ButtonSend onClick RECEPIENT Stephen
04-01 14:12:29.211: D/BirthdayEditor(950): ButtonSend onClick MESSAGE Congrats
04-01 14:12:29.251: W/System.err(950): java.lang.NullPointerException
04-01 14:12:29.261: W/System.err(950):  at android.os.Parcel.readException(Parcel.java:1431)
04-01 14:12:29.261: W/System.err(950):  at android.os.Parcel.readException(Parcel.java:1379)
04-01 14:12:29.261: W/System.err(950):  at com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:434)
04-01 14:12:29.261: W/System.err(950):  at android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
04-01 14:12:29.261: W/System.err(950):  at com.chr.tatu.sample.friendslist.contacts.BirthdayEditor$2.onClick(BirthdayEditor.java:110)
04-01 14:12:29.261: W/System.err(950):  at android.view.View.performClick(View.java:4202)
04-01 14:12:29.272: W/System.err(950):  at android.view.View$PerformClick.run(View.java:17340)
04-01 14:12:29.272: W/System.err(950):  at android.os.Handler.handleCallback(Handler.java:725)
04-01 14:12:29.272: W/System.err(950):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-01 14:12:29.272: W/System.err(950):  at android.os.Looper.loop(Looper.java:137)
04-01 14:12:29.272: W/System.err(950):  at android.app.ActivityThread.main(ActivityThread.java:5039)
04-01 14:12:29.272: W/System.err(950):  at java.lang.reflect.Method.invokeNative(Native Method)
04-01 14:12:29.272: W/System.err(950):  at java.lang.reflect.Method.invoke(Method.java:511)
04-01 14:12:29.272: W/System.err(950):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-01 14:12:29.272: W/System.err(950):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
</code></pre>

<p><strong>Manifest.xml:</strong></p>

<p>I have given <em>permission to Send SMS</em></p>

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