0

I am working on the android application. In this application i have to connect to the ble device. I want the application connected to the ble device when the application is in background .

1 Answers1

3

The answer is to have at least one Foreground Service https://developer.android.com/guide/components/services.html#Foreground in your process that uses BLE. That will make Android keep your process alive.

Emil
  • 16,784
  • 2
  • 41
  • 52
  • So that means the bluetooth work does not need to be inside the service, but the service just needs to run "next" to the bluetooth listeners etc.. , so the app stays alive? – 最白目 Dec 20 '22 at 06:18
  • Correct. The same process that has BluetoothGatt objects needs to have a Foreground Service running. – Emil Dec 20 '22 at 06:43