25

I created a BroadcastReceiver and configured it with an android.provider.Telephony.SMS_RECEIVED action filter so it is called everytime the phone receives a text.

Is there some event/action or other way for my application to be notified whenever the phone sends a text (preferably independent of the application that sends it)?

So far the only option I see is to poll the content provider for content://sms/sent which doesn't even give me all sent texts because applications can choose not to put it there.

Josef Pfleger
  • 74,165
  • 16
  • 97
  • 99
  • As the API for sending SMS messages (android.telephony.gsm.SmsManager) allows developers to specify custom intents to be broadcasted when sending succeeds or fails, I don't think it's possible to listen for a single "sms message sent" intent. – Henning Jul 06 '09 at 21:53
  • Hi Josef, I am wondering have tou made any more advances with this? I can currently listen out for messages being sent via a content observer but I would like to stop the sms from being sent over the GSM/CDMA network and sent over a data connection instead. Would you have any insight into how to block an sms from sending over GSM/CDMA? – Donal Rafferty Apr 01 '10 at 11:59

1 Answers1

21

Unfortunately there is (currently) no way to implement a BroadcastReceiver because the standard sms application uses a SmsManger to send the messages but specifies concrete internal classes for the sent and delivered intents (SmsReceiver.class and MessageStatusReceiver.class respectively). Not that it is any consolation but you can find the following comment in the Sms application's source:

// TODO: Fix: It should not be necessary to
// specify the class in this intent.  Doing that
// unnecessarily limits customizability.

The best alternative seems to be polling content://sms/sent, potentially using a ContentObserver.

Josef Pfleger
  • 74,165
  • 16
  • 97
  • 99
  • Hi Josef, I am wondering have tou made any more advances with this? I can currently listen out for messages being sent via a content observer but I would like to stop the sms from being sent over the GSM/CDMA network and sent over a data connection instead. Would you have any insight into how to block an sms from sending over GSM/CDMA? – Donal Rafferty Mar 31 '10 at 11:45
  • 1
    No, unfortunately. But I think *blocking* the message is going to be even trickier. I'll let you know if I think of something. Meanwhile, try asking a question on stackoverflow.com ;-) – Josef Pfleger Apr 01 '10 at 12:17
  • Of course a ContentObserver only plays nicely with those applications that actually use the SMS/MMS content store. Which some messaging apps (and all malicious apps) don't do. – Phil Haigh Oct 02 '13 at 13:50