Monday, January 18, 2010

Launching SMS/Messages Activity using Intent

Category: SMS
Subcategory: SMS/Messages Activity, Intent
Android Platform: 1.5, Google APIs 3
Referenced Classes: android.content.Intent

As with other Android Apps, you can launch the built-in SMS/Messages Activity using an intent, as described in the following thread (http://jtribe.blogspot.com/2008/12/sending-sms-using-android-intents.html). In order to pre-populate the recipients (or "To" text box) in this manner, set the address attribute on the calling intent:
code snippet
Intent sendIntent= new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "smsBody");
sendIntent.putExtra("address", "phoneNumber1;phoneNumber2;...");
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
Note, multiple recipients can be passed using a semi-colon delimited list.

3 comments:

  1. hi. based on the above code i want to code the condition when sms is successfully deleivered. how will i use it...

    ReplyDelete
  2. it doesn't work on android...
    when i put a phone number in address nothing appear in the "To" text box

    ReplyDelete