TiGer
TiGer

Reputation: 5949

Issue receiving SMS in KitKat

I am having a little issue with the new SMS semantics introduced in KitKat (4.4) : https://developer.android.com/about/versions/android-4.4.html#SMS

I have the following situation with an app I developed in Jelly Bean :

The system receives an SMS and I hook into that with a broadcast-receiver listening to android.provider.Telephony.SMS_RECEIVED. I check if the SMS is specifically for my app, if so I abort the broadcast so that it is not send to the default SMS receiver app. If not meant for my app I do not abort the broadcast and it lands in the messages inbox of the device...

With the new KitKat semantics (my app not being a default SMS app) I still do receive the SMS but I am not able to abort the broadcast, thus resulting in my app-specific SMS message landing in the default SMS app's inbox, which is not what I want.

Thus my question is if it's possible to maintain my old workflow (thus preventing the SMS to be passed to the default SMS app after having scanned the SMS, i.e the old abortBroadcast()-method) or otherwise transform my app to a "default SMS app" but being able to route it anyways to a second "default SMS app" if the SMS was not meant for my app ?

After looking around a bit and finding other threads like : Abort SMS Intent on Android KitKat I am guessing my first option would not work, so I am hoping that my second option (re-route to another SMS-receiving app) is feasible !

Upvotes: 0

Views: 434

Answers (1)

Mike M.
Mike M.

Reputation: 39191

...my question is if it's possible to maintain my old workflow (thus preventing the SMS to be passed to the default SMS app after having scanned the SMS, i.e the old abortBroadcast() method)...

No. The default SMS app listens for a broadcast unique to it, that cannot be intercepted or aborted. (The SMS_DELIVER broadcast.) I would also mention that the SMS_RECEIVED broadcast can no longer be aborted, so any app listening for that will get it.

...transform my app to a "default SMS app" but being able to route it anyways to a second "default SMS app" if the SMS was not meant for my app...

Nope. If your app is the default SMS app, it needs to handle everything involved with incoming messages, including receiving, processing, storing, etc. You can't "hand it off".

It's not really possible to prevent an incoming message from being written to the Provider, if your app is not the default. However, I do have a workaround that might allow your non-default app to delete a message once received and written. (This solution currently works in only KitKat. I've not yet got it working with Lollipop.)

Upvotes: 1

Related Questions