Android learning notes-use intentservice

Source: Internet
Author: User

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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.