About Android Service
What is Service?
· Service indicates "Service ".
· Service is one of the core components of the Android system.
-Service is essentially a Java class that inherits android. app. Service.
-Each Service should be registered in the AndroidManifest. xml file;
-The Service is maintained by the Android system.
Service Positioning
· The Service does not have a matched user interface, which is usually used for background processing time-consuming operations.
· Time-consuming operations cannot be performed in the main thread. ,
· The Service is running in the main thread;
· Although the Service is positioned as "processing time-consuming operations", various time-consuming operations must be performed in
In Service.
· Components can be bound to the Service to implement Inter-Process Communication (IPC: Inter Process Communication)
Process Priority
· The Android system tries to maintain as many processes as possible, but due to limited device performance, in the process of dynamic memory management,
Android often terminates low-priority processes to release resources and ensure normal operation of high-priority processes.
Process priorities are classified as follows (from high to low ):
1. Foreground Process (Foreground Process)
(1) There is an Activity that is interacting with the user;
(2) A Service exists, and the Service is bound to the Activity that interacts with the user;
(3) The startForeground () of the Service is called.
(4) There is a Service that is executing the core lifecycle method. Including: onCreate (), onSrart ()
, Onsrartcommandroid (); onDestroy ();
(5) A broadcast receiver is receiving the broadcast.
2. Visible Process)
There are no front-end components, but they contain user-visible components, such:
(1) A paused Activity
(2) A Service bound to a visible Activity exists.
3. Service Process)
(1) The Service is started using startService (), but the Service is not raised to the "front-end", "visible"
"Level
4. Background Process)
Most of them are activities after onStop ().
5. Empty Process)
Processes that do not contain any active components. To facilitate caching of components and improve the efficiency of the next startup, the system may temporarily retain
They
Note: only the first three processes that contain services