如何查看短信发送报告。在后台发送短信时

时间:2019-05-09 03:30:45

标签: android kotlin sms

我要创建一个在后台发送短信的应用。但是以MI(Redmi)手机为例。我无法获得任何交货报告。但在其他所有手机上都能正常工作的任何人都可以帮助我,我在这里发布我的代码。

if (readSmsPermission == PackageManager.PERMISSION_GRANTED) {

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
val sManager = getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager

             val infoSim = sManager.getActiveSubscriptionInfoForSimSlotIndex(getSimSlot?.toInt()!!)!!

                    SmsManager.getSmsManagerForSubscriptionId(infoSim.subscriptionId).
                            sendTextMessage( to , "", text,sentPI, sentPI)
                }

            }

//这是我的广播,有待定的意图

  val sendReceiverIntent  = sendSmsIntent()

    val sentPI = PendingIntent.getBroadcast(this, 0, intent, 0)

    registerReceiver(sendReceiverIntent,IntentFilter("SMS_DELIVERED"))

0 个答案:

没有答案