Android--activity and how the service is started

Source: Internet
Author: User

1. There are four ways to start the activity (Android:launchmode)

(1) Standard: default mode, do not configure again

The Standart mode is a stack mode, and by default each jump to a new activity will create a new instance, regardless of whether the instance exists. Each jump on the new, press stack, each return on the pop stack.

(2) Singletop: android:launchmode= "Singletop" is specified for <activity>, and the stack top reuse mode.

Each time you judge the stack top there is no, no, create; have, continue to use. If a corresponding activity is found at the top of the stack, it is reused and does not create a new one.

(3) Singletask: Specifies the android:launchmode= "Singletask" for the <activity> attribute, the unique mode.

For example, if you jump from secondactivity instance to firstactivity, you can secondactivity the stack without creating a new

Features: Each activity instance is unique, and as long as the stack exists, it pops up all of his activity. Ensures uniqueness of each activity instance

(4) SingleInstance: A relatively unique pattern, each activity will have a single stack, this stack only allow the activity of the instance into the stack

2. Service A total of two start-up methods (to be perfected)

(1) Context.startservice () mode start: OnCreate ()--onstartcommand (OnStart () obsolete)--ondestory ()

Once the service is turned on, the service has nothing to do with the caller. The server will continue in the background, regardless of whether the opener is launched or hung.

(2) Context.bindservice () mode start: OnCreate ()--onbind ()--onunbind ()--ondestory ()

Bind mode to open the service, service bindings, the caller hangs, the server will also hang up, the binder can invoke the service inside the method.

Android--activity and how the service is started

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.