Search code examples
androidsmsandroid-contentresolver

Android, Detect which app is sending SMS?


Is there a way to detect the app which is sending the intercepted SMS?

In my code I can intercept both outgoing and incoming SMS, read body, phone number etc but I don't know if there is a way to detect the app/package which is sending the SMS. I have searched but had no luck. Thanks in advance. I am using the below library to intercept short messages:

Sms Radar on GitHub

Note that I'm not talking about the app which is the default messaging app. Sometimes other apps like WhatsApp send SMS to authenticate the user. These type of SMS won't be visible inside outbox/sent messages, although I can detect them at the point of send/receive.

So I just want to know exactly which app (package name) is right now sending the SMS.


Solution

  • So I found a workaround. During when an app is sending a short message, it is a foreground process. So I just got the list of foreground processes when my onSMSSent() got called and found the app that is sending SMS, at the top of the list.

    Though this might not be a solid solution, but as @Ch4t4r said, it seems there is no solution to directly get the SMS sending app and the trick sounds good enough.