0

I am trying to combine flutter_foreground_tasks with BLE scanning, whether the app is running visibly or in the background, everything works perfectly. But as soon as I turn off the screen and the log message goes through. I/FA (24762): Application backgrounded at: timestamp_millis: ... nothing works anymore. No matter how I try it. With continuous scanning, or every 6 seconds in onRepeatEvent (so that startScan is not called more than 5 times in 30s), it no longer delivers any results.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

I have turned on all possible permissions

<service android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
android:foregroundServiceType="dataSync|remoteMessaging|connectedDevice" android:exported="false" android:stopWithTask="false" />
and also tried several combinations in ForegroundService.

Does anyone else have an idea what else I could try to wake the phone up again when I find a very specific BLE device?

Logs

D/[FBP-Android](29081): [FBP] onMethodCall: startScan
D/BluetoothAdapter(29081): isLeEnabled(): ON
D/BluetoothLeScanner(29081): onScannerRegistered() - status=0 scannerId=19 mScannerId=0
[log] startScan
[log] scanResults.listen(0)

further informations are here

https://github.com/boskokg/flutter_blue_plus/issues/924

0

Browse other questions tagged or ask your own question.