android-ble-made-easy
android-ble-made-easy copied to clipboard
BLE instance in service
I wanted to use the library in Foreground Service, but at the moment it's not possible. Could you please add a context-only constructor?
Hello, Thank you for your issue It is theoretically possible, although I have never tested this on a Service, so it would need testing.
Would you be so kind to offer help to test the library given that I expose a new constructor for you?
I'd be happy to play around with this - I have a need for BLE in a Foreground Service in a small project I'm working on and I'd love to use this library to make it happen!
Thank you for volunteering! I will put out a prototype with this as soon as I get time to it, so we can get this into a new version.
Just updating this with my findings.
- We need special permission to handle connected devices on a foreground service
- Couldn't find a way to handle the jetpack contracts on the services, so it may be possible that using helpers like hardware availability, permission checking and so on wouldn't work
- It may be only possible to start the BLE instance on an Activity, Fragment or Jetpack compose activity, connect to a device and then pass the connection instance to the service.