This is more of a general question, but to what extent can we use the Nearby Connections API in services?
I noticed that discovery and pairing is still working while the app is out of focus, so is it possible to extract the whole connections client into a foreground- or even a background service which is running while the app itself doesn't have to?
There are no restrictions on using Nearby Connections from a service. However, Android has always somewhat aggressively killed background services (and is more aggressive since Android Oreo). There's also no way to limit the power, so advertising, scanning, and maintaining a connection for a long period of time will adversely effect battery life. There's a plan to expose a low power flag, but there's no ETA.
Disclaimer: I work on Nearby Connections