[Apidemos for Android samples video series] app-activity-forwarding

Source: Internet
Author: User

1. Preface

The demo analysis references the mapdigit article about API demos. On the basis of this article, I further analyzed related knowledge points.


2. Demo

3. Demo Analysis

Android applications can contain multiple activities. One activity can start another activity. These activities are managed using the stack structure. Newly opened activities are stacked on the current activity, and the current activity stops running. When an activity stops running, the android system retains its status before it stops. When you press the "back" button, the activity at the top of the stack is pushed back from the top of the stack, the previous activity is moved to the top of the stack and displayed on the screen:

Sometimes, when an activity starts a new activity, it does not want to keep the current activity in the activity stack. For example, when the activity is used to implement a confirm dialog, when the user confirms and starts a new activity, the user does not want to display the confirm dialog when the new activity is displayed after "back.


In the example, fowarding uses finish () to end the current activity while starting the new activity.


Intent intent = new Intent();  intent.setClass(Forwarding.this, ForwardTarget.class);  startActivity(intent);  finish();  

Finish the forwarding activity, and then press "back" to return to the apidemo-> activity sample list instead of forwarding.


4. Video Explanation:



5. We learned the following demo:


1. Four methods to exit the Android Application




Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.