When [tag:Foreground Service] is running and User taps on Clear all from recent Apps then it is stopping the service.It's happening only in specific devices Such as MI, Redmi, Xiaomi etc.
I couldn't found the it's solution.
I want to prevent the service from Stopping even if user taps clear all from recent task.
The service can not running forever. You can suggest to user exclude your app from battery optimization and allow autostart. In such case you can use
WorkManagerwith foreground request to do long running operations when app is not running and can be started from background (depends from other permissions like location and etc).The other options is suggest to user hold app in recently list. Some of launcher from vendors provide feature with "hold/lock" button. So when user click
clear all, app that hold have to stayed.