Android's return key and Activity, androidactivity

Source: Internet
Author: User

Android's return key and Activity, androidactivity
I encountered a problem when I started the application, that is, some data needs to be loaded in advance when I started the home page. I processed the data in a load page and then forwarded it to the home page, however, when I press the return key on the home page, the system returns to load the page. I do not want the page to be retained in the task after use. The default relationship between the returned stack, task, and activity described in the Android official document: 1: When Activity B is started from Activity A, Activity A stops, but it saves its status (for example, scrolling position and text in the form ). If you press the return key in Activity B, Activity A restores the previous status. 2: when the user presses the Home key, the current activity stops, and its tasks are placed in the background. The system saves the status of each activity in the task. If you start the app again, the task returns to the foreground and displays the activity at the top of the stack. 3: If you click BACK, the current activity pops up from the stack and is destroyed. If the activity is destroyed, the system will not save its status. 4: The Activity can be instantiated many times, even from different tasks.
Of course, you can change its default status by adding a flag to the manifest file or the intent in the startup Activity. Intent. setFlags (Intent. FLAG_ACTIVITY_NO_HISTORY); // The newly started activity will not be saved in the history stack.
Next we will introduce a common flag: FLAG_ACTIVITY_NEW_TASK: The newly started activity will start a new task in this history stack.
You can find the identifier you need in the Intent class introduction in this document.

Android return key to close the current activity

I have installed a testkiller and can close the program at will.
It is the best off program software I have used.

Detailed call process for destroying an activity by pressing the return key in android

When you press the back key, onDestroy () is called to destroy the current activity. When you restart this activity, onCreate () is called for reconstruction;
When you press the home key, the onStop () method is called and the activity is not destroyed. When you restart the activity, onResume () is called ().
 

Related Article

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.