Service
1. What is service?
1. It is used to process time-consuming operations
2. Is an applicationProgramBuild
3. There is no graphical interface and it cannot be the same as activity
4. You can use the service to update contentprovider, send intent notifications, and start the system.
2. What is service?
1. Not a separate process
Process: it has its own independent memory space. A process can contain multiple threads.
2. Not a thread
Thread: does not directly own computer memory resources
Iii. Lifecycle
4. How to start and stop the service
1. Start a service and call on creat ()/on start command ()
The first call to the Service will start on creat (), which is a life cycle function.
In fact, the main function of writing a service is implemented in on start command ().
2. If a service is destroyed, on destory () is called ()
3. A service must be registered in manifest. xml.
Code: Intent = new intnet ();
Intent set class (testactivity. This, firstservice. Class );
Start Service (intnet );
Stop Service (intnet );