I have recently added to my app a feature enabling sharing screen over the network. This feature becomes especially meaningful when I want to stream the mobile screen outside my app, i.e. putting my app in background. While I have no problem on a Samsung S7 with Android 8, the app is constantly killed on a Samsung Active Pro after being 5 minutes in background. However, if the tablet is connected to the usb cable (either to a charger or to my PC) the app remains alive.
I have disabled battery optimizations for my app and tried other possible user-side actions found on the web without success.
Is there anything I can do developer-side? I've tried to use wakelocks, but that didn't help. In other threads I have read that sending notifications with a foreground service might help: is this a viable solution?
you need to have an foreground service, otherwise the OS will kill you app