2

I'm trying to insert this message into the SMS Provider as below:

String json = "{
    "sADDRESS": "0874521447",
    "sBODY": "yes",
    "sDATE": "1574675807896",
    "sREAD": "1",
    "sSTATUS": "-1",
    "sTYPE": "2"
  }"
Gson gson = new Gson();
UserMessage message = gson.fromJson(json);

ContentValues values = new ContentValues();
values.put(SmsConsts.BODY, message.getBody());
values.put(SmsConsts.ADDRESS, message.getAddress());
values.put(SmsConsts.TYPE, message.getType());
values.put(SmsConsts.DATE, message.getDate());
values.put(SmsConsts.STATUS, message.getStatus());
values.put(SmsConsts.THREAD_ID,
Telephony.Threads.getOrCreateThreadId(mContext,message.getAddress()));
values.put(SmsConsts.READ,message.getRead());

mContext.getContentResolver().insert(Telephony.Sms.CONTENT_URI,values);

This code is not working in Android 10. The only way to see the message after the insert is by clearing storage for the messages app in the app info. I've tried to install another app from the Play Store, and I can see the message in this app after an insert.

Is there anything I'm missing and should do in order to make it work in Android 10?

Mike M.
  • 38,532
  • 8
  • 99
  • 95
Thair Jaber
  • 117
  • 1
  • 8

0 Answers0