I am developing an app using Codename One, which connects to a Bluetooth LE proprietary external device and logs received data (on average data arrives approximately once per second). I am using the Bluetooth LE CN1 library (a wrapper for Cordova Plugin).
The app should be able to receive and log the data even when not in foreground, which I have no idea how to do in CodenameOne in a way that the system wont shut it down on its own.
I've written a native Android app, where I use a service with a persistent notification for the duration of the connection with the external BTLE device - the background service exits when connection is lost (or user cancels the connection). Is there any way to do the same thing in CodenameOne, which will work both on Android and iOS? I know I could write native code to do that, but I'm sceptical if I can still use the plugin - I would like to avoid writing the whole bluetooth connection module of the app native for both OSes, as that kind of negates the point of using CodenameOne.
I haven't tried doing it by just spawning a java thread, as that looks like it wouldn't really work since it's converted to native code... or does it?
PS: I've searched for a solution to my problem, the closest i could find is CodenameOne Background Music playback, but this is meant only for music playback, as far as I can understand it.