When using the flutter_foreground_task plugin to keep a foreground service alive in a Flutter application (e.g., for background BLE data collection or sensor streaming), the service works as expected on most Android devices. However, on Xiaomi/MIUI phones, the service is immediately killed when the user clears the app from the recent tasks list, even though a foreground notification is displayed.
This behavior occurs despite the service being marked as foreground and running correctly in the background prior to the recent task clear action. It seems to be due to aggressive task and background process management in MIUI, which overrides standard Android lifecycle expectations and got permission from user to disable battery optimisation too.
is there any specific solution to overcome this
When using the flutter_foreground_task plugin to keep a foreground service alive in a Flutter application (e.g., for background BLE data collection or sensor streaming), the service works as expected on most Android devices. However, on Xiaomi/MIUI phones, the service is immediately killed when the user clears the app from the recent tasks list, even though a foreground notification is displayed.
This behavior occurs despite the service being marked as foreground and running correctly in the background prior to the recent task clear action. It seems to be due to aggressive task and background process management in MIUI, which overrides standard Android lifecycle expectations and got permission from user to disable battery optimisation too.
is there any specific solution to overcome this