StartService () and bindservice () differences

Source: Internet
Author: User

1. Life cycle:
StartService () mode starts, the service is received by intent and will experience OnCreate () and OnStart (). When the user experiences OnDestroy () when the intent is made to destroy it, the Bindservice () mode starts, and when the activity is bound, it experiences oncreate () and Onbind (), and when the activity is destroyed, The service first calls Onunbind () and then OnDestroy ().

2. Control mode:
The former control mode needs to use a fixed method, a single operation of the service. The latter is bound to the activity, regardless of its life cycle problems, and from the sending intent passive operation, to be able to actively operate the service object, we can even establish a handler class, the service related operations. The flexibility and operability of the service are greatly enhanced.

Summary: For simple application StartService () Start-up mode can bring less code, simple operation. The Bindservice () approach to complex applications, while bringing in more coding, also brings better operability, making it more activity-like.

StartService () and bindservice () differences

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.