In our app, we are trying to send SMS progrmmatically. For 20% devices app is not able to send SMS. We are getting "RESULT_ERROR_GENERIC_FAILURE" error from sms receiver in most cases and in most cases sms is not being sent from device itself.
Below is the code snippet we are using for sending sms.
private fun sendSms(subscriptionId: Int, number: String, smsText: String, sentPI: PendingIntent?, listener: ISmsSendListener) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
SmsManager.getSmsManagerForSubscriptionId(subscriptionId).sendTextMessage(number, null, smsText, sentPI, null)
} else {
SmsManager.getDefault().sendTextMessage(number, null, smsText, sentPI, null)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…