Android Learning Notes-Nineth chapter loading mode of activity

Source: Internet
Author: User

The Nineth chapter of activity loading mode

  1. Task: Similar to a stack, each time the interface is opened, a task is created and then the Open interface is placed into the task.

    (1) Standard: default mode

    Each time a new interface is created to add the interface to the task

    (2) Singletop: Stack Top Single instance mode

    A. If the target activity does not exist, create a new activity and deposit into the task

    B. If the target activity already exists and is at the top of the stack, no new activity will be created

    C. If the target activity already exists, but not at the top of the stack, create a new activity to store in the task

    (3) Singletask: Single Instance in stack

    A. If the target activity does not exist, create a new activity and deposit into the task

    B. If the target activity already exists and is at the top of the stack, no new activity will be created

    C. If the target activity already exists but is in the stack, all activity above the target activity will be destroyed

    (4) SingleInstance: Global Single Instance

    A. If the target activity does not exist, create a new task and a new activity to deposit the activity into the task

    B. If the target activity already exists, move the activity's task to the foreground to show

  2. Single-instance (singleton, single-state) SingleTon

    (1) Declaring a class, privatizing its construction method

    Private SingleTon () {}

    (2) Create an object of this class type

    private static SingleTon SingleTon = new SingleTon ();

    (3) public static SingleTon getinstance () {

    return singleTon;

    }

    (4) test

  3. Intent flag bit

    Set the intent flag bit

    Intent.setflags (INTENT.FLAG_ACTIVITY_XXX);

    A. Intent.flag_activity_single_top:

    Similar to Singletop (stack top single instance) in Load mode

    B. Intent.flag_activity_clear_top:

    The effect is similar to Singletask in load mode, destroying all activity on the target activity (including itself) and then creating a new activity

    C. Intent.flag_activity_new_task:

    Note: If the startactivity jump interface is in service, the intent flag bit must be set.

Android Learning Notes-Nineth chapter loading mode of activity

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.