Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun startScan(filters: List<ScanFilter>, settings: ScanSettings = defaultSettings): ReceiveChannel<ScanResult?> {
- val channel = Channel<ScanResult>()
- scanCallback = object : ScanCallback() {
- override fun onScanResult(callbackType: Int, result: ScanResult) {
- channel.offer(result)
- }
- }
- scanner.startScan(filters, settings, scanCallback)
- return channel
- }
- fun startScan(scope: CoroutineScope, filters: List<ScanFilter>, settings: ScanSettings = defaultSettings): ReceiveChannel<ScanResult?> = scope.produce {
- scanCallback = object : ScanCallback() {
- override fun onScanResult(callbackType: Int, result: ScanResult) {
- offer(result)
- }
- }
- scanner.startScan(filters, settings, scanCallback)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement