• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps What is the best approach to work with BLE device in background?

Currently I am working on an application which has BLE peripheral, my app works as master and the BLE device works as peripheral.

The app has below mentioned use cases:

  1. The application should connect and communicate with the BLE device even if the app is not in foreground. (app can be in background or closed)
  2. Once the app is connected to the BLE device we need to get the data in our application and process on it.
  3. So the basic use case which needs to be achieved is, once the BLE device is in our device's range it should connect and communicate with our app , whereas once its out of our device's range it should stop the communication process.
All these things should work well even if our app is in background or closed state.

As per the background limitations from oreo as mentioned in this link https://developer.android.com/about/versions/oreo/background , we can not use services to achieve this scenario.

Currently we are using foreground services to achieve the desired use case, but not sure if that is the best approach to work with.

Please let me know the best approach which can be used to achieve the above mentioned use case using the latest android api.

Note: Our app has minimum sdk version 23 and target sdk version 28
 
Back
Top Bottom