Process Lifecycle
The Android system will attempt to keep the process hosting a service around as long as the service has been started or has clients bound to it. When running low on memory and needing to kill existing processes, the priority of a process hosting the service will be the higher of the following possibilities:
-
If the service is currently executing code in its
onCreate()
,onStartCommand()
, oronDestroy()
methods, then the hosting process will be a foreground process to ensure this code can execute without being killed. (前台进程)