views:

67

answers:

0

Android isn't firing the delivery intent when sending a text message. I'm testing this on Android 2.2 on the HTC EVO 4G.

This is the current code. I'm seeing "SMS sent intent received." in the logs, but not "SMS delivered intent received.".

// Constants
String SENT_ACTION = "SMS_SENT_ACTION";
String DELIVERED_ACTION = "SMS_DELIVERED_ACTION";
String CELL_NUMBER = "0000000000";
String MESSAGE = "Hello World!";

// SMS sent pending intent
PendingIntent sentIntent = PendingIntent.getBroadcast(this, 0,
        new Intent(SENT_ACTION), 0);

// SMS delivered pending intent
PendingIntent deliveredIntent = PendingIntent.getBroadcast(this, 0,
        new Intent(DELIVERED_ACTION), 0);

// SMS sent receiver
registerReceiver(new BroadcastReceiver(){
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "SMS sent intent received.");
    }
}, new IntentFilter(SENT_ACTION));

// SMS delivered receiver
registerReceiver(new BroadcastReceiver(){
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "SMS delivered intent received.");
    }
}, new IntentFilter(DELIVERED_ACTION));

// Send the SMS message
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(CELL_NUMBER, null, MESSAGE, sentIntent, deliveredIntent);