I am working on a BLE app (using RxAndroidBle library!) that is able to connect to multiple devices for quite a while. Recently business requirements have slightly changed and I have to preserve connection with all the devices throughout whole app. What I mean after I connect with the device I have to keep stable connection on all the screens and If I get disconnected I have to prompt the user about that.
Until now I had some kind of a BleManager
that was an abstraction over RxBleClient
and BleDevice
that was an abstraction over RxBleDevice
.
Both those classes were covered with some reactive interfaces, they were injected into proper modules and all the subscribing and unsubscribing them were done in those specific screen modules.
However now I have to change the approach because I have to keep the connection all the time.
The question is: Is there any better way to keep the stable connection with the Ble Device other than creating it in Android Service and keeping the subscriptions in that Service? All the Ble examples/tutorials keep those connection in the service but I'm not a big fan of this solution as it also doesn't fit very well in my architecture. I was wondering if I could bind this somehow with the application instance or something like that. Any idea other than service will be very much appreciated.