I have a strange problem on Android API 27 and higher. I have an app for our fire department, that checks every received SMS, and react to it, if the sender is a specified number. (We use SMS alarming, and this app must fire up on each SMS alarm and start doing stuff). Everything works perfectly for android version 26 and below. But for higher versions, the app stops reading received SMSs after a few hours. I need to go to apps permissions to manually disable and re-enable SMS permission, then it works for a few hours again!! Arrrghhh
I have a BroadcastReceiver class with onReceive function and i have it declared in the Manifest.
The permission is asked with this code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED)) {
requestPermissions(arrayOf(Manifest.permission.READ_SMS), REQ_SMS_READ)
}
What am I doing wrong here?
Thanks so much for your input!