Set PendingIntent when sending MMS

This commit is contained in:
Naveen 2023-01-10 16:54:55 +05:30
parent a48a160632
commit 0095352713
3 changed files with 8 additions and 4 deletions

View File

@ -21,6 +21,7 @@ import com.simplemobiletools.smsmessenger.extensions.isPlainTextMimeType
import com.simplemobiletools.smsmessenger.extensions.smsSender
import com.simplemobiletools.smsmessenger.messaging.SmsException.Companion.ERROR_PERSISTING_MESSAGE
import com.simplemobiletools.smsmessenger.models.Attachment
import com.simplemobiletools.smsmessenger.receivers.MmsSentReceiver
import com.simplemobiletools.smsmessenger.receivers.SendStatusReceiver
class MessagingUtils(val context: Context) {
@ -158,6 +159,9 @@ class MessagingUtils(val context: Context) {
}
}
val mmsSentIntent = Intent(context, MmsSentReceiver::class.java)
transaction.setExplicitBroadcastForSentMms(mmsSentIntent)
try {
transaction.sendNewMessage(message)
} catch (e: Exception) {

View File

@ -110,13 +110,13 @@ class SmsSender(val app: Application) {
}
private fun getSendStatusIntent(requestUri: Uri, subId: Int): Intent {
val intent = Intent(SendStatusReceiver.MESSAGE_SENT_ACTION, requestUri, app, SmsStatusSentReceiver::class.java)
val intent = Intent(SendStatusReceiver.SMS_SENT_ACTION, requestUri, app, SmsStatusSentReceiver::class.java)
intent.putExtra(SendStatusReceiver.EXTRA_SUB_ID, subId)
return intent
}
private fun getDeliveredStatusIntent(requestUri: Uri, subId: Int): Intent {
val intent = Intent(SendStatusReceiver.MESSAGE_DELIVERED_ACTION, requestUri, app, SmsStatusDeliveredReceiver::class.java)
val intent = Intent(SendStatusReceiver.SMS_DELIVERED_ACTION, requestUri, app, SmsStatusDeliveredReceiver::class.java)
intent.putExtra(SendStatusReceiver.EXTRA_SUB_ID, subId)
return intent
}

View File

@ -21,8 +21,8 @@ abstract class SendStatusReceiver : BroadcastReceiver() {
}
companion object {
const val MESSAGE_SENT_ACTION = "com.simplemobiletools.smsmessenger.receiver.SendStatusReceiver.MESSAGE_SENT"
const val MESSAGE_DELIVERED_ACTION = "com.simplemobiletools.smsmessenger.receiver.SendStatusReceiver.MESSAGE_DELIVERED"
const val SMS_SENT_ACTION = "com.simplemobiletools.smsmessenger.receiver.SMS_SENT"
const val SMS_DELIVERED_ACTION = "com.simplemobiletools.smsmessenger.receiver.SMS_DELIVERED"
// Defined by platform, but no constant provided. See docs for SmsManager.sendTextMessage.
const val EXTRA_ERROR_CODE = "errorCode"