I'm developing an Android app that reads data from a Bluetooth device and saves it to disk (and perhaps send some data to a server). The Bluetooth device is a wearable with a heart rate sensor and a bunch of other sensors. It sends data to the Android app every second or so.
The app works fine when in foreground, but when in background, it gets killed after a few minutes (usually 15 to 30 min).
I understand the concepts of foreground and background services and it seems like what I need here is a foreground service (correct me if I'm wrong) to make sure the process doesn't get killed. It's a pain however because I'll have to move most of my app's classes in remote objects in the foreground service classes.
However! I noticed that just creating a simple foreground service and binding my main activity to it makes it so that the activity doesn't get killed as fast, as a matter of fact I tested it for an hour and a half and everything was still running smoothly in the main activity process.
Could that just be the solution I'm looking for? Or do I really have to move most of my classes in remote objects in a more complex foreground service?