Return value issues for service class Onstartcommand in Android

Source: Internet
Author: User
During Android development, the Onstartcommand (Intent,int,int) method of the service object is called every time StartService (Intent) is called. Then do some processing in the Onstartcommand method. Then we notice that this function has an int return value, and this article simply tells the effect of the int return value. From the official Android documentation, we know that Onstartcommand has 4 return values: Start_sticky: If the service process is killed, the status of the reserved service is the start state, but the delivery intent object is not preserved. The system then tries to recreate the service, and since the service status is started, the Onstartcommand (Intent,int,int) method must be called after the services are created. If no startup commands are passed to the service during this time, then the parameter intent will be null. Start_not_sticky: "Non-sticky". When this return value is used, the service is not automatically restarted if the service is killed by an exception after Onstartcommand is executed. Start_redeliver_intent: Retransmission INTENT.  With this return value, if the service is killed by an exception after Onstartcommand is executed, the service is automatically restarted and the value of intent is passed in. Start_sticky_compatibility:start_sticky compatible version, but does not guarantee that the service will be restarted after kill.

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.