1

I have an SMS app that maintains its own SMS database, separate from the main system database used by Messages and other typical SMS apps. I would like to make it so that when another app sends an SMS (such as Google Now, or MightyText, or other GUI-less methods for sending an SMS) that message is imported into the app I'm working on. To do this, I need to trigger an action when an SMS is sent and/or when an outgoing SMS is saved to the system SMS database.

Is there a broadcast intent I can register to listen for to catch this? If not, what's the lowest overhead way to watch for and react to this event?

The IFTTT and Tasker apps can listen for sent SMSes, so I know it's possible. Unfortunately neither are open source, so I can't see how they do it.

Sparr
  • 7,489
  • 31
  • 48
  • I'd really appreciate some feedback from downvoters. I'm happy to rephrase the question or provide more details if that would help. – Sparr Dec 01 '16 at 20:19

1 Answers1

0

Have you looked through Telephony SMS Intents? There seems to be something promissing like RESULT_SMS_HANDLED

Another possibility is to observe changes in content provider of sms inbox (Telephony.Sms.Inbox.CONTENT_URI). But that's I think is only possible while your app is running.

shtolik
  • 1,341
  • 22
  • 29
  • RESULT_SMS_HANDLED isn't an intent, it's just one possible result code for the SMS_*_ACTION intents. – Sparr Dec 01 '16 at 22:05
  • Is there any way to request notifications for changes to a content provider? polling seems super inelegant. – Sparr Dec 01 '16 at 22:05
  • Seems there is an answer for that with example here: http://stackoverflow.com/questions/9520277/practical-way-to-find-out-if-sms-has-been-sent/9659025#9659025 – shtolik Dec 01 '16 at 22:09
  • And if you only want to observe sent sms's you may only subscribe to "content://sms/sent" https://developer.android.com/reference/android/provider/Telephony.Sms.Sent.html – shtolik Dec 01 '16 at 22:15