Write to SMS Content Provider in KitKat without Being Default SMS App
Alongside the various user-facing and security-related changes introduced Android 4.4 KitKat, Google also significantly modified how the SMS Content Provider works. In Android 4.4, users can now select a default SMS app from within Settings -> Wireless & Networks. Then, two intent broadcasts are sent: one for all SMS apps (SMS_RECEIVED_ACTION) and one for only the default SMS app (SMS_DELIVER_ACTION). Thus, non-default SMS apps are able to receive incoming SMS messages, but they are not able to do certain things such as abort the broadcast.
Despite the positive effect on software modularity afforded by being able to select a default SMS app, the change also brings a few limitations. Namely, in order to delete (or restore) an SMS message, your app must temporarily become the default app if it isn’t already. This is problematic from a UX standpoint because there will be two mandatory prompts, where the user must select the default SMS app: one to select your app and one to revert.
Thankfully, XDA Senior Member stepic came up with a workaround that allows app developers to write to the SMS Content Provider in KitKat without being the default SMS app. Stepic made his discovery by looking in the Android source code and finding a special permission: OP_WRITE_SMS. Unfortunately, this workaround either requires user interaction or root access. However, this is only a one-time affair, rather than two prompts for user input every time a non-default SMS app needs to perform certain tasks.
If you’re an app developer looking to make an SMS app for KitKat, head over to the guide thread to learn more about this workaround.
Want something on the XDA Portal? Send us a tip!