rxandroidble

How to autoconnect to a BLE device when app is not in foreground using rxandroidble?


According to the docs:

Unlike the native Android API, if autoConnect=true while using this library there will be NO attempts to automatically reconnect if the original connection is lost.

I'd like the phone/app to be connected when back in range even if the app is not being used when it happens, I don't really care about the app, just need the phone to be connected.

If I'm not mistaken, the native API would trigger a reconnection even if the app is not running as long as the devices are paired/bonded (is that assumption correct?).

How could I achieve this using RxAndroidBle? Is running a foreground service with an annoying sticky notification the only way?


Solution

  • If I'm not mistaken, the native API would trigger a reconnection even if the app is not running as long as the devices are paired/bonded (is that assumption correct?).

    This assumption is not correct. You would still need the process which started the connection to be around.

    How could I achieve this using RxAndroidBle? Is running a foreground service with an annoying sticky notification the only way?

    You have answered your question — the same statement is true when using the native API (which used by RxAndroidBle under the hood actually)