Facing crash issue with SecurityException while sending SMS programmatically on OS 11. Also, this issue is happening on live users of the application but while testing I am unable to reproduce so If anyone encounters the same then please revert
Scenario:
We are sending SMS to a particular number if the user grants the SMS permission.
Devices:
This crash occurs only for Samsung devices with Android 11.
Code:
SmsManager.getSmsManagerForSubscriptionId(subscriptionId)
.sendTextMessage(destinationAddress, null, getString(R.string.xyz)
.format(token), sendSMSPendingIntent, null)
Below are the crash logs
java.lang.SecurityException: Package com.android.phone (uid=1001) does not match provided uid 10246
android.os.Parcel.createExceptionOrNull Parcel.java:2385
android.os.Parcel.createException Parcel.java:2369
android.os.Parcel.readException Parcel.java:2352
android.os.Parcel.readException Parcel.java:2294
com.android.internal.telephony.ISms$Stub$Proxy.sendTextForSubscriber ISms.java:2102
android.telephony.SmsManager$1.onSuccess SmsManager.java:618
android.telephony.SmsManager.sendResolverResult SmsManager.java:1627
android.telephony.SmsManager.resolveSubscriptionForOperation SmsManager.java:1588
android.telephony.SmsManager.sendTextMessageInternal SmsManager.java:613
android.telephony.SmsManager.sendTextMessage SmsManager.java:451```