I have extended the Template app in nRF Toolbox. When my app runs in the background on an Android 8 (only) device and I try to connect to the peripheral, I get this error when trying to execute startService(service) in BleProfileServiceReadyActivity:
java.lang.IllegalStateException: Not allowed to start service Intent { ... }: app is in background
This is expected as pointed out here and elsewhere: https://stackoverflow.com/questions/46445265/android-8-0-java-lang-illegalstateexception-not-allowed-to-start-service-inten
What is Nordic's advice:
Q1 On this topic in general?
Q2 How should the Template app be changed to support BLE Library operation in the background?
Q3 Is there a sample Android app (all versions) that will scan for BLE advertisments at all times (including when the app is in the background and/or the phone has been reset)
and then spring into life, connect to the peripheral and interact with it?
Q3 is what I am really trying to do. The Android Beacon Library addresses the problem, but is specific to beacons. IMHO this is a sufficiently important use case that it deserves
a robust example from Nordic.
Thanks