Hi franck,
First of all, I highly recommend switching to BLE Library. In fact, the version 2 of it, which is now in beta6 phase, will very soon be the only maintained version, so please use this one. Despite the beta in the name, it's well tested and has more features then 1.2.
nRF Toolbox uses this beta version on *develop* branch.
However, the BLE Library only handles the connection. It may be used in a service, in view model (or repository inside), in an activity for some simple use cases, etc. On its own it doesn't care about how it's being used, so also does nothing regarding the changes in Android Oreo.
On the other hand, the nRF Toolbox, which is using this library, should care about all those issue, and should start its services as foreground service. It has been pointed today: https://github.com/NordicSemiconductor/Android-nRF-Toolbox/issues/57 that it isn't doing that, and the running service will be likely killed 5 minutes after the app went to background. I'll fix it before the nRF Toolbox *develop* is merged to *master*.
You may also check [nRF BLinky](https://github.com/NordicSemiconductor/Android-nRF-Blinky), which is using Architecture Components and is handling the connection from the View Model. But in that case we don't support background connection at all, that's why it's possible.
Hope that answers your questions,
Aleksander
Hello Aleksander,
Thank you for your answer, my question regarding background services was more related on BleProfileService in nrf toolbox which is not indead part of BLE Library but which is derived in nrf toolbox template
Our need is that our application can also work in in background so I guess that nrF Blinky is not the best example to start with
We already started to customize template exemple in NRF toolbox 2.6.0 (latest official release) which is based on Ble library 1.2.0.
So you advise us to restart using NRF toolbox alpha 3.0.0-alpha1 version that is working on top of BLE Library 2 ?
Thanks,
Franck
Hello Aleksander,
Thank you for your answer, my question regarding background services was more related on BleProfileService in nrf toolbox which is not indead part of BLE Library but which is derived in nrf toolbox template
Our need is that our application can also work in in background so I guess that nrF Blinky is not the best example to start with
We already started to customize template exemple in NRF toolbox 2.6.0 (latest official release) which is based on Ble library 1.2.0.
So you advise us to restart using NRF toolbox alpha 3.0.0-alpha1 version that is working on top of BLE Library 2 ?
Thanks,
Franck
Yes, that would be my advise. To keep the service running you just need to start it as a foreground service. In order to do that, call startForeground(..). Before that you also need to create the notification channel.
Check out how do we do it in DFU: https://github.com/NordicSemiconductor/Android-DFU-Library/blob/release/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java#L723
Yes that is what we need, a service that is foreground and keep on running when activity become not visible and is stopped or destroyed