I am developing an Android Application with Android Studio in Java, that should do the following thing: Connect with one or multiple BLE-Devices and receive GATT-notifications of those over a long period of time (4-10h) in the background. I wrote a Service for this which sends me an android notification when a critical value is received and only hands the data to my Activity, when the app is opened.
The whole thing works fine on the LG G6 I am testing with and also on a Huawei Mate 10 Pro. Now I wanted to try the same App on a Samsung S9 (and S8) and the result was, that the background service stopped after 2 or 3 minutes...
I've run through every energy setting of the phone, that I found and I thought it could cause this trouble, but I found nothing.
Therefore my question: What does Samsung do different from LG and Huawei? Are there any known issues? I have no idea, what may be the problem.
The problem was indeed, that I did not use a foreground service like HarmenH told in the comments. Since I use a foreground service instead of a bound service, everything works as expected on every phone. I can't tell you why the behaviour diverged between the different phones, but since I use the correct way it does not matter anymore. I recommend to dive into Android services overview if you are struggeling with a similar problem.