In my xamarin forms project, BLE scan works for long time in foreground, but when app switches to background, scan stops suddenly after sometime. It depends on phone models. Xiaomi redmi phone stops scan exactly at 1 minute. Motorola stops at a later time. None of the models scans for 1 hour. Issue happens with screenlock also. I need to work scan for long hours in background. Scan is started using a foreground service
but then also scan stops. Tried with WorkManagerJob
also. Scan starts like this: _bluetoothLeScanner?.StartScan(filterList, settings, _bluetoothScanCallback);
Any other way to extend scanning for long hours in background and screenlock? Help needed...
Asked
Active
Viewed 417 times
0

Vipin Krishna
- 355
- 1
- 4
- 25
-
When you use `foreground service` it stoped, Is the notification is disappear? Your application was closed by the inbuilt battery saving feature in MIUI. Please try following advice to make the applicaion running in background in MIUI https://stackoverflow.com/questions/43607869/how-to-run-a-background-service-even-the-app-is-killed-in-mi-devices/52317301 – Leon Sep 21 '20 at 11:49
-
@LeonLu-MSFT foreground service is not stopping. notification is still there. only scan stopped – Vipin Krishna Sep 21 '20 at 12:30
-
If the notfication is still there, normally, scan will not be stopped. Did you try to add the scan to the Timer, every second to scan once. – Leon Sep 21 '20 at 12:54
-
i have not tried. i wil check – Vipin Krishna Sep 21 '20 at 13:00
-
tried. still same result after 1 min – Vipin Krishna Sep 21 '20 at 13:38