I am implementing an app, that has to do some heavy sensor(even with location) data collection while user does some activity.
To do this, when user clicks the start collection, I create a foreground service to ensure continuous collection of the data. It works fine on most devices, but on Huawei P20 if I close the screen at some point (could be 5 minutes, could be less, or more) it kills the app and foreground service. This does not seem to be cased when the device is in a charger.
I know a foreground service could be killed if the device needs memory etc., but during my tests the device was only running my app, so there should not have been a need to kill the application.
Any advice would be appreciated.