Android Apidemos Sample Resolution (7) App->activity->forwarding

Source: Internet
Author: User

Android apps can contain, multiple activity, and an activity can start another activity. These activity is managed using the stack structure, and the newly opened activity is stacked on top of the current activity, and the current activity stops running. When an activity stops running, the Android system retains its state before it stops, and when the user presses the "Back" button, the top activity from the stack is pushed off the stack, and the previous activity moves to the top of the stack, which is displayed on the screen:

Sometimes, when an activity starts a new activity, it does not want to keep the current activity on the activity stack, for example, when a confirm dialog is implemented using an activity, when the user confirms and starts a new activity, Do not want to display confirm Dialog when the new activity is displayed by pressing "back".

Example fowarding uses finish () to end the current activity while starting a new activity.

Intent Intent = new Intent ();  

   
Intent.setclass (Forwarding.this, forwardtarget.class);     
StartActivity (intent);     
Finish ();

Finish finishes forwarding activity, then press "Back", then go straight to the Apidemo->activity sample list, not forwarding.

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.