sweetpoision
sweetpoision

Reputation: 77

Do I need to manually insert new messages in content://sms/inbox?

Started learning android for college project recently. I have created an SMS app which is capable of being a default app(minimalistic app though). When I set it to default SMS app, my phone's inbuilt app stopped receiving new messages.

Questions:

  1. Do all new messages automatically go in content://sms/inbox or do we have to update it manually ? I am asking this because my inbuilt SMS app doesn't reflect the SMS received while it was not default SMS app.

  2. Is it necessary to forward new messages to other apps listening for new SMS received?

Upvotes: 2

Views: 363

Answers (1)

Mike M.
Mike M.

Reputation: 39191

Do all new messages automatically go in content://sms/inbox or do we have to update it manually ?

No, those messages will not be written to the inbox automatically. The default app is responsible for saving all incoming SMS to the Provider. Though there is no requirement for the default app to do so, if it doesn't save them there, then other apps that query the Provider to read existing messages just won't see them. This would explain why your inbuilt SMS app doesn't see the new messages received while yours is the default.

The only message writes that are handled automatically by the system are for outgoing SMS sent by non-default apps. All other inserts, updates, and deletes are left up to the default app.


Is it necessary to forward new messages to other apps listening for new SMS received?

Not specifically, as it were. Any non-default app that is interested in getting messages as they arrive should be listening for the SMS_RECEIVED broadcast, and the system will send that automatically. Such apps have direct access to the messages, since they're attached to the broadcast Intents as extras.

Beyond that, pretty much the only other (practical) way for non-defaults to read messages, or to be notified of changes, is through the Provider, so as long as you're saving the messages there, such apps are covered, as well.

Upvotes: 2

Related Questions