I'm developing an android app using kotlin. When I write some logic about scanning BLE devices, no matter what I wanna do, it needs permission. For example, in this function, I ask for permissions.
private fun startBleScan() {
    if (Build.VERSION.SDK_INT >= 21 && !isLocationPermissionGranted) {
        requestLocationPermission()
    }
    if (ActivityCompat.checkSelfPermission(
            this,
            Manifest.permission.BLUETOOTH_SCAN
        ) != PackageManager.PERMISSION_GRANTED
    ) {
        requestBleScanPermission()
    }
    bleScanner.startScan(scanFilters, scanSettings, scanCallback)
    }
But when I wanna working with stopBleScan, it also needs permissions.(I haven't add yet, now ide tells me to add permissions)
private fun stopBleScan() {
    bleScanner.startScan(scanCallback)
}
At last, when I wanna use result.device.name, ide also tells me it needs permission.(Without permission, I can only use result.device, I don't know why).
private val scanCallback = object : ScanCallback() {
    override fun onScanResult(callbackType: Int, result: ScanResult) {
        with(result.device) {
            Log.i("ScanCallback", "$name") // ide tells me it needs permission, this line doesn't work
            foundDevice = true
        }
    }
}
Is there any solution, so I can only ask permissions for one time, I think it is normal otherwise do it everytime. I'm really new to kotlin and BLE, please help me, Thank you in advance!
 
     
    