Recipe 5.3 Monitoring the Status of Sent SMS Messages Programmatically

Android Versions
Level 4 and above
Source Code to Download from

When sending SMS messages programmatically, you might want to monitor the sending status to ensure that the messages are sent and delivered correctly.


To monitor the status of the SMS message sending, you need to make use of two PendingIntent objects: one for tracking when the message is sent, and another one for tracking whether the message is delivered correctly. You also need two BroadcastReceiver objects, so that you can listen for intents when the SMS message has been sent and delivered:

package net.learn2develop.sendsmswithfeedback;

import android.content.BroadcastReceiver;
import android.os.Bundle;

public class MainActivity extends Activity {
    String SENT = "SMS_SENT";
    PendingIntent sentPI, deliveredPI;
    BroadcastReceiver smsSentReceiver, smsDeliveredReceiver;

    public void onCreate(Bundle savedInstanceState) {

NOTE What is the difference between a sent message versus a delivered message? A sent message means that the message has been sent successfully from the sender’s phone; but it may or may not be delivered to the recipient. For example, a message ...

Get Android Application Development Cookbook: 93 Recipes for Building Winning Apps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.