Apr 5, 2011

How to send SMS using android.telephony.SmsManager

android.telephony.SmsManager manages SMS operations such as sending data, text, and pdu SMS messages. Get this object by calling the static method SmsManager.getDefault(). It supports both GSM and CDMA; please don't mix up with deprecated android.telephony.gsm.SmsManager.

  SmsManager MySmsManager = SmsManager.getDefault();
String PhoneNumber = "123....67"; //fil with the receiver's phone number
String SMSText = "Hello Android";
MySmsManager.sendTextMessage(PhoneNumber, null, SMSText, null, null);


3 comments:

  1. Hi Eric, this SMS is not valid for sending the SMS having the message text greater than 160 characters. How can we send the sms with character more than 160 words?
    Thank you.

    ReplyDelete
    Replies
    1. Hello,

      As I know it's limited by SMS standard, may be you can separate the text in two (or more) message.

      Delete
  2. If instead of a phone number, I use a short code (5 digit number) the message goes nowhere.

    ReplyDelete

Infolinks In Text Ads