1

I have created an android sms app that sends message using SmsManager

smsManager.sendTextMessage(number, null, msg, sentPI, deliveredPI);

My app doesn't store sms to database but somehow other default sms app intercepts my sms and store it to database. How default sms app intercepts it when i am not saving sms to database in case it has content observer. I am also sure sendTextMessage() method doesn't store sms to database because when my app becomes default sms app i have to store them manually aftere sendTextMessage().

fishLegs
  • 113
  • 10
  • 1
    The default app isn't responsible for that. The system handles saving messages sent by non-default apps using `SmsManager`. – Mike M. Jan 05 '22 at 16:26
  • than why system doesn't handle that when my app becomes default app – fishLegs Jan 05 '22 at 16:27
  • 1
    Just because that's how they decided to do it. The default is responsible for every message that it touches, basically. Messages sent by other apps using `SmsManager` never go through the default, though, so they apparently figured it was just easier to save those automatically. – Mike M. Jan 05 '22 at 16:27
  • so if my app becomes default than system will handle when other apps try to send message? – fishLegs Jan 05 '22 at 16:29
  • Yes, when those other apps use `SmsManager` to send messages, the system will automatically save those. You only need to worry about messages that your app sends itself. – Mike M. Jan 05 '22 at 16:30
  • i got it what you want to say, thx. You should post answer to my question. There was no such info available on stackoverflow – fishLegs Jan 05 '22 at 16:30
  • Cool. I should point out that the SMS API wasn't originally available in the SDK back in the day, before KitKat, but people were using it anyway, and when they finally decided to publish it, they had to make allowances for how it was already being used by some very popular apps, so some of the "rules" for it don't make much sense. Just FYI. – Mike M. Jan 05 '22 at 16:36
  • I've a little more relevant info about it in [my answer here](https://stackoverflow.com/q/51490859). – Mike M. Jan 05 '22 at 16:36
  • but that question is very general. no one can guess the problem lies with default sms rules. My question is more specific. – fishLegs Jan 05 '22 at 16:40
  • I didn't say the questions were the same. :-) You said "There was no such info available on stackoverflow", but there is, in that answer. – Mike M. Jan 05 '22 at 16:41
  • thats hidden info i would say. – fishLegs Jan 05 '22 at 16:43
  • i could never find that unless you told. I spent two days searching for how to intercept outgoing sms. I was thinking that default sms apps have some kind of privilaged channel that delivers them info of outgoing sms of my app. – fishLegs Jan 05 '22 at 16:48
  • 1
    Yeah, it's easy to get too focused on the first possible mechanism one might think of. I still do it myself occasionally. Sometimes you just gotta completely start over, again and again and again. :-) Cheers! – Mike M. Jan 05 '22 at 16:58

0 Answers0