The difference between Android back key and home key

Source: Internet
Author: User

Back key

Android programs do not have to deliberately quit, when you press the back of the phone, the system will default to call the top activity in the program stack Destroy () method to destroy the current activity. When this activity is started again by other activity, the OnCreate () method is called again to create, and when all activity in the stack pops up, the application ends. If there is a service in the program, It is possible to listen to the processing in the right place.

Home Key

Android program is hidden, when you press the phone's home button, the system will default to call the top activity in the program stack Stop () method, and then the entire application will be hidden, when you click on the Phone Desktop app icon again, The system invokes the Onresume () method of the topmost activity, which does not reopen the program, but directly enters, showing the topmost activity in the stack.

The back key defaults to the current activity to the Finish,home key only to the activity to OnStop.

Back Key Imitation home key function:

@Override  Public void onbackpressed () {     // Implement home key effect      //    new  Intent (intent.action_main);     I.setflags (intent.flag_activity_new_task);     I.addcategory (intent.category_home);     StartActivity (i);  }

The difference between Android back key and home key

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.