Joke Collection Website - Blessing messages - Androidservice is started. Under what circumstances will it be started?

Androidservice is started. Under what circumstances will it be started?

Android service automatically shuts down after it is started. Reason:

Android system has its own set of methods for memory management. In order to ensure the orderly and stable operation of the system, the system will automatically allocate and control the memory usage of the program. When the system feels that the current resources are very limited, in order to ensure that some high-priority programs can run, it will kill some programs or services that it considers unimportant to release memory. This will ensure that programs that are really useful to users will still run again. If this happens to your service, it is likely to be killed first. But if you increase the priority of the service, you can make it stay a little longer. We can use setForeground(true) to set the priority of the service.

The service started by default is marked as background, and the currently running activity is generally marked as background, which means that if you set a background for the service, it will have a higher priority similar to the running activity. This does not guarantee that your service will never be killed, but it only improves its priority.