foregroundService property
[Android only]
Configure the plugin service to run as a more robust "Foreground Service".
Android 8.0+
Defaults to true
and cannot be set to false
. Due to strict new Background Execution Limits in Android 8, the plugin enforces foregroundService: true
.
A persistent notification is required by the operating-system with a foreground-service. It cannot be hidden.
Android < 8.0
Defaults to false
. When the Android OS is under memory pressure from other applications (eg: a phone call), the OS can and will free up memory by terminating other processes and scheduling them for re-launch when memory becomes available. If you find your tracking being terminated unexpectedly, this is why.
If you set this option to true
, the plugin will run its Android service in the foreground, supplying the ongoing notification to be shown to the user while in this state. Running as a foreground-service makes the tracking-service much more immune to OS killing it due to memory/battery pressure. By default services are background, meaning that if the system needs to kill them to reclaim more memory (such as to display a large page in a web browser).
Note: See related config option Notification:
:blue_book: For more information, see the Android Service docs.
Implementation
bool? foregroundService;