I have a reminder application that will send an SMS to notify the user that the reminder time has passed. It works well. However, I tested what happens when the phone was asleep and missed a reminder.
I use AlarmManager
to configure alarms corresponding to reminder times. My log shows that the alarm went off when the phone rebooted and an attempt to send an SMS occurs, but the SMS is never received.
So the question is, is there a way to debug, why is SMS not sent?
My current code sets ContentObserver when an alarm event occurs:
private void registerToListenForSentSMS() { MessageSentListener smsObeserver = new MessageSentListener(new Handler()); ContentResolver contentResolver = TheEveryOtherAlarmAppApplication.getAppContext().getContentResolver(); contentResolver.registerContentObserver(Uri.parse("content://sms"), true, smsObeserver); }
MessageSentListener receives a notification that an SMS event has occurred:
public class MessageSentListener extends ContentObserver { public MessageSentListener(Handler handler) { super(handler); } @Override public void onChange(boolean selfChange) { super.onChange(selfChange); Log.d(Constants.ALARM_APP_LOG_TAG, "Something happend"); ContentResolver contentResolver = AlarmAppApplication.getAppContext().getContentResolver(); contentResolver.unregisterContentObserver(this); } }
But this may be caused by SMS events not related to my application. In any case, this does not bring me closer to a solution - I would like to know what went wrong when nothing happens!
If the SMS message is not sent, I can either resend it or use another notification method, for example, email, etc.
barry source share