Service class onstartcommand in Android

Source: Internet
Author: User

During Android development, every time startservice (intent) is called, The onstartcommand (intent, Int, INT) method of the service object will be called, and some processing will be done in the onstartcommand method. Then we noticed that this function has an int return value. Article It is to briefly explain the function of int return values. From the official Android documentation, we know that onstartcommand has four return values: Start _ Sticky: if the service process is killed, the Service State will be retained to the starting state, but the intent object for delivery will not be retained. Then the system will try to re-create the service. Because the service status is starting, the onstartcommand (intent, Int, INT) method will be called after the service is created. If no startup command is passed to service during this period, the intent parameter is null. Start _ Not_sticky: "non-viscous ". When this return value is used, if the service is kill abnormally after onstartcommand is executed, the system will not automatically restart the service. Start _ Redeliver_intent: Re-transmits intent. When this return value is used, if the service is kill abnormally after onstartcommand is executed, the system automatically restarts the service and passes in the intent value. Start _ Sticky_compatibility: Start _ Sticky compatible version, but it is not guaranteed that the service will be restarted after it is killed.
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.