Skip to content Skip to sidebar Skip to footer

Sms Doesn't Save On Kitkat 4.4

My Sms app does not save the sms to the device even though I already set it as the default messaging. I need to support android pre-kitkat so I did a bit researching and had 2 Broa

Solution 1:

Even though you've got the Receivers set up to get the system broadcasts, you still need to store the messages retrieved from them; for example:

ContentValuesvalues=newContentValues();
values.put(Telephony.Sms.Inbox.ADDRESS, smsMessage.getDisplayOriginatingAddress());
values.put(Telephony.Sms.Inbox.BODY, smsBody);
values.put(Telephony.Sms.Inbox.DATE, System.currentTimeMillis());
values.put(Telephony.Sms.Inbox.PROTOCOL, smsMessage.getProtocolIdentifier());
values.put(Telephony.Sms.Inbox.READ, 0);
values.put(Telephony.Sms.Inbox.SEEN, 0);
values.put(Telephony.Sms.Inbox.SERVICE_CENTER, smsMessage.getServiceCenterAddress());
values.put(Telephony.Sms.THREAD_ID, Telephony.Threads.getOrCreateThreadId(context, address));

UriinsertUri= context.getContentResolver().insert(Telephony.Sms.Inbox.CONTENT_URI, values);

Starting with KitKat, the default SMS app is responsible for writing all incoming messages to the Provider, so when your app is the default on those versions, you definitely need to save the messages from the SMS_DELIVER broadcasts.

Pre-KitKat, there was no such thing as a default SMS app, so the user had to ensure to have at least one messaging app, often pre-installed, that would handle saving messages voluntarily, but it was kind of a free-for-all. If you're supporting those versions, you might need to handle inserting messages there too, if no other app is doing it.

Post a Comment for "Sms Doesn't Save On Kitkat 4.4 "