In the previous recipe we had no way of knowing for sure if our message had been correctly sent or not. To monitor the success or otherwise of SMS messages we need to use a PendingIntent to trigger some activity once the action is completed. We will also need a BroadcastReceiver to pick up on our message sends.
This exercise is much the same as the last but here we will provide a way of monitoring our message's progress.
This task picks up from where the previous one left off, so if you have not yet done so, quickly complete it now and return here, it is very short and will not take long.
Along with the button and
EditText
field declarations in the Java code add these:PendingIntent sendIntent; PendingIntent receiveIntent; String sent = "MESSAGE_SENT"; String received "MESSAGE_DELIVERED"; BroadcastReceiver sendBR; BroadcastReceiver receiveBR;
Inside the
onCreate()
callback, set up aPendingIntent
for when the message is sent and one for when...