Intentservice is a subclass of the service class and is used to process asynchronous requests.The client can pass the request to intentservice through the startservice (intent) method. intentservice processes each intent object through worker thread and stops the service automatically after all the work is completed.
Note:The worker thread processes all the requests passed, creates a worker queue, and transmits only one intent to the onhandleintent at a time, so that you do not have to worry about the problems caused by multithreading. The stopself () method is automatically called after processing. The onbind () method is implemented by default, and the return value is null;
The startcommand () method is implemented. This method will be put in the worker queue, and then 0 will be executed in onhandleintent ().
Two steps are required to use intentservice:
1. Write Constructor
2. Rewrite onhandleintent () method
Benefits:Write can be reduced when processing asynchronous requests.CodeTo easily meet project requirements.
(Process all requests passed through) Work