Service preliminary (1) ------- notes

Source: Internet
Author: User

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 );

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.