return keys and activity in Android

Source: Internet
Author: User

I encountered a problem when I was working on my application that I needed to preload some data when I started the main page, I was working on a load page and then went to the main page, but when I pressed the back key in the main page, the system returned to the loading page. I don't want the load page to remain in the task after it's been used. The default relationship for return stacks, tasks, and Activity as described in the official Android documentation: 1: When activity B is started from activity A, activity a stops, but saves its state (for example, scrolling position and text in the form). If the user presses the return key in activity B, activity a reverts to the previous state; 2: When the user presses the home key, the current activity stops and its task is placed in the background. The system will save the status of each activity in the task, and if the user launches the app again, the task will return to the foreground and show the activity;3 at the top of the stack: if the user clicks the back key, the current activity is popped out of the stack and destroyed. If the activity is destroyed, the system does not save its state; 4:activity can be instantiated many times, even from different tasks.
Of course you can change its default state by adding a flag to the manifest file or to the intent that launches the activity.intent.setflags (intent.flag_activity_no_history);//The newly started ACTIVITY will not be saved in the history stack
introduce a common flag:Flag_activity_new_task: The newly launched ACTIVITY will open a new task in this historical stack
You can find the logo you need in the intent class in the documentation.

return keys and activity in Android

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.