when my app was using Android5, I can monitor if the SMS was sent or failed by checking the content://sms/sent and content://sms/failed. Aside from via my app, I can also see the message and its status directly from the SMS app of the phone.
Now that the good old Android5 smartphone is dead, I am upgrading to a newer smartphone base on Android8 (Oreo). However I am facing a problem of detecting the status of the sent sms.
First… I can no longer "see" the sms using the phone’s default SMS app.
Second… I cant also find the sms using my app even if I scroll through all messages one by one.
This is the code I use to send the SMS:
smsManager := TJSmsManager.JavaClass.getDefault;
smsTo := StringToJString(targetstr);
smsarray := smsmanager.divideMessage(stringtojstring(bodystr));
smsManager.sendmultiparttextMessage(smsTo, nil,smsarray, nil, nil);
While this is the code I use to scroll through all my messages:
uri := StrToJURI(‘content://sms’);
smscursor := TAndroidHelper.Activity.getContentResolver.query(uri, nil, nil,nil,nil);
id_id := smscursor.getColumnIndex(StringToJstring(‘_id’));
idaddress := smscursor.getColumnIndex(StringToJstring(‘address’));
idbody := smscursor.getColumnIndex(StringToJstring(‘body’));
idstatus := smscursor.getColumnIndex(StringToJstring(‘status’));
idthread_id := smscursor.getColumnIndex(StringToJstring(‘thread_id’));
idtype := smscursor.getColumnIndex(StringToJstring(‘type’));
** using the repeat until loop to read each and every sms until "islast" is true **
But I cant find the sent SMS irregardless if the SMS was successfully sent or not.
I need to do this detection because the signal strength in my area is very low and around 20% of the time the sms failed, and my app should resend the intended message.
PS: I also tried searching for the SMS from the content://sms/sent and content://sms/failed but to no avail.
Anyway, my questions are:
How to make the send out sms show up inside the phone’s default sms app?
How to correctly determine if the send out sms was successful or not?
I read somewhere that the method above is using the API and there is a way to use the phone’s sms app instead… But I dont have any idea how to do it.