Android 8 requires READ_PHONE_STATE when calling SmsManager.sendTextMessage()

一曲冷凌霜 提交于 2019-11-30 04:43:01

This is a bug in android O that so much annoying. if you check SmsManager.java you can see getSubscriptionId method that in body need READ_PHONE_STATE_PERMISSION and if you don't give READ_PHONE_STATE throw SecurityException

So all you can do is generate READ_PHONE_STATE and explain it to play store if you've been warned or wait to fix by google developers

You need to check the permissions in android nougat devices.

 if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS)
         != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this,
               Manifest.permission.SEND_SMS)) {
            } else {
               ActivityCompat.requestPermissions(this,
                  new String[]{Manifest.permission.SEND_SMS},
                  MY_PERMISSIONS_REQUEST_SEND_SMS);
            }
      }

Link - https://www.tutorialspoint.com/android/android_sending_sms.htm
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!