1. A service is a reliable component with unbounded boundaries. Reliability means that a service is generally not shut down when it is started, even if the application process of the service is killed, it also runs continuously, unless the memory resources are insufficient, shut down unexpectedly, or the code is used to close it. The intent sent from the outside is repeatedly executed by the service to ensure the service quality.
2. When a service is enabled and the service is enabled again, a new instance object of the service is not generated, but a new instruction is sent to the original service instance, execute the onstartcommand () method in the service. Therefore, it is best to write the operation code of our own application in this method. If it is written in onstart (), it may not be executed.
3. There are two methods for starting a service: startservice () and onbind () method to start the service (send new commands ).
Startservice and bindservice can both start the service. What is the difference between them? The difference between them is to change the service cycle. The service started by startservice must have stopservice to end the service. If you do not call stopservice, the activity ends and the service is still running. The service started by bindservice can be ended by unbindservice, or automatically ends after the activity ends (ondestroy.