Android Service parsing

Source: Internet
Author: User

1.startService

A. There is a sense of starting a thread that is not related to activity after startup.

B. will not be automatically destroyed and need to be destroyed by man (including service after binding)

C. Only one service is started in the thread, and when StartService is called multiple times, Onstartcommond is started more than once, and the OnCreate method is not called

2.bindService

A. A kind of server and client feeling, service for server, activity for client

B. Starting only one service, when Bindservice is called multiple times, does not invoke any method of service. A service is only bound by one activity until the activity calls Onbind

C. When the activity is destroyed, the bound service is also destroyed, with the exception that Activit calls the Onunbind method if the service is started in StartService and calls the Onstartcommond method before the destruction.

And back to true, the service is not destroyed at this time, and when the activity is bindservice again, the Onrebind method is called back to the IBinder, knowing that calling StopService destroys the service

Additional:

Service life cycle diagram:

    

Android Service parsing

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.