Hi I am new to coroutines. I am having an issue wi...
# coroutines
a
Hi I am new to coroutines. I am having an issue with delay function. I have a foreground service in which I am starting bluetooth scanning then delaying for 20 seconds and then calling stopScan. Now, scan result is start coming 20 seconds late, is it because of delay?
code snippet example is here
message has been deleted
g
Not sure that it directly related to coroutines, it more like an implementation detail of this mManager (it’s really not clear what kind class it is, it doesn’t look as BluetoothLeScanner API)
a
Its a wrapper written for doing different BT operation on device. startScan function is using core BluetoothLeScanner API internally to do scanning and then onScanResult() is receiving devices data which came into scan list. My concern is, delay of 20 seconds shouldn’t affect scanning process as I can see as soon I call start scan function, scanning is started. is delay function stopping main thread?
g
No, delay function is not stopping main thread
it looks like some other problem in your wrapper
maybe it waits until stopScan() is called
r
Definitely an implementation detail, depending on your scan settings or scan mode, the scan results might not be delivered until scanning is finished, hence the "delay" you are seeing. I recommend using the default scan settings and you should see the expected behavior.
a
@gildor and @reline thanks a lot for clearing doing, problem was in BT manager class itself.