Well, I solved the problem just making 3 differences. First you will put "override" before the "fun" keyword. Then delete the question marks in front of
"Array" this and "grantResults: IntArray" this.
It should be "Array?" , "grantResults: IntArray?" like this at the beginning just delete the question marks.
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && requestCode == REQUEST_PERMISSIONS_REQUEST_CODE && permissions!!.size == 2 &&
permissions[0] == Manifest.permission.ACCESS_FINE_LOCATION && permissions[1] == Manifest.permission.ACCESS_BACKGROUND_LOCATION) {
if (grantResults!![0] == PackageManager.PERMISSION_GRANTED && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
// Permissions granted, background mode can be enabled
enableBackgroundMode()
result?.success(1)
result = null
} else {
if (!shouldShowRequestBackgroundPermissionRationale()) {
result?.error("PERMISSION_DENIED_NEVER_ASK",
"Background location permission denied forever - please open app settings", null)
} else {
result?.error("PERMISSION_DENIED", "Background location permission denied", null)
}
result = null
}
}
return false
}