Android SDK provides apis for sending sms and receiving SMS
The two primary classes as part of android.telephony package used for developing SMS application are
SMS Send :
SMSManager class has api sendTextMessage(String destination_Address,String service_center address,String message,
PendingIntent sentIntent,Pending deliveryIntent)
destination_Address : MDN no of sms receiver
Service_center_address :The service center address is retrieved from SIM.If null,sms packet will be routed to default MSC
Message :text message to send.
Pending Intent (android.app.PendingIntent)
Android has provided PendingIntent class which defines an intent and the components which can handle the intent to perform specific task.
The sent pendingIntent,sendIntent which is called from telephonic framework when sms is sent.
SMS is sent when sms packet is received by SMSC.
Delivery Intent :
The pendingIntent deliveryIntent defines an the application component which is fired when telephoy framework broadcast the delivery status of message. The SMSC forwards the message to SMS receiver .When it receives ack from sms receiver,it sends special message called Status report. This is sent only when sender has requested for delivery report.The particular field has to be set in SMS pdu packet. When telephony framework receives the status report message,it broadcast the sms delivery status.
The delivery intent is null if user has not enabled message delivery option in Message setting.
The instance of sent penidingIntent,si is obtained by
PendingIntent si = PendingIntent.getBroadcast(context, 0, new Intent(“SMS_SENT_ACTION), 0);
The above argumented context must register broadcast receiver sentIntent :
By registering broadcast receiver,the sentIntent receiver is called when sms sent event is dispatched by SMSDispacther of Telephony Framework. through si.send() call.
BroadcastReceiver sentIntent =new BroadcastReceiver(
public void OnReceive(Intent intent)
case :A\ctivity.OK :
“sms sent successfully ,move to sent folder with sent status”
case : SMSManager.RESULT_ERROR_GENERIC_FAILURE :
“sms failed ”
“push the message in the sms queue database,message will be sent when network service will be available,move to outbox”
} } );
The Application sends next message when the sent intent of previous message is arrived.Each typed message is queued in sms database.The next message from the top of the queue is taken when sent event of previous message is processed.This way messages are sent sequentially.
The delivery Intent di is obtained by
PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent(“SMS_DELIVERED_ACTION), 0);
Like sentIntent,the context has to register broadcast receiver,which be would handled when sms application receives the delivery of the message from framework
through delivery intent
The telephony intent broadcast with the deliveryIntent’s intent and the receiver deliveryIntent is triggered.
BroadcastReceiver deliveryIntent =new BroadcastReceiver(
public void onReceiver(Intent intent)
“sms delivered update the status of sms to delivered in the sent folder”
SMS Framework :SMS Apis,sendtextMessage calls SMS framework classes.The main class is SMSDispatcher which handles incoming and outgoing sms transaction and interacts with application through intent.The sms framework can send sms over CS(circuit switched) or PS(packet switch) network
For CS,framework will make RIL request to RIL(radio interface layer) layer of android telephony,RIL layer sends request to MODEM.MODEM route sms packet in form of data burst message to Base station.
For PS,Framework dispatch pdu to SIP stack ,which forms SIP(session initiation protocol) packet and send to registered SIP server. The SMS framework is part of phone process and it is initialized on bootup. SMS framework forms transport layer sms pdu from the input parameters ,destination_no,message,sent intent,delivery intent.
The pdu is formed as per 3gpp2 sms Specification for sms over CDMA channel and 3gpp spec for sms to be sent over GSM based channel.
SMS RECEIVE :
Whenever phone boots up,the smsDispatcher(part of phone process),registers itself as handler to RIL(radio interface layer)
Whenever RIL receives unsolicited sms receive command from MODEM,it calls the sms handler with NEW_SMS_RECEIVE event and
smsDispatcher post the sms receive event to SMS application. The SMS application receives the new sms intent from framework and intent data contains SMS pdu which is byte array. The application creates android.telephony.SMSMessage object from received pdu through SDK class
The message display to display on UI can be obtained from msg Object as
String origination_no = msg.getDisplayOriginatingAddress()
The application should include the required permissions android.permission.SEND_SMS and android.permission.RECEIVE_SMS in sms application’s android.manifest file.
Jainendra Kumar is Android developer. He has rich experience in developing commercial Android application. He received B.E (Gold Medalist) from BIT Mesra and M.S from BITS Pilani.