Android Application running mode and priority

Source: Internet
Author: User

Android applications have their default running modes. To understand it, you must understand the activity lifecycle and visibility cycle.


Once the program is executed, it first enters oncreate and onstart. The rewrite method can be selected through eclipse. The method is relatively simple. Just right-click the blank area of the class that integrates the activity and choose source> override/implement methods.

In the displayed dialog box, select the onstart method to be rewritten.

Eclipse generates the followingCode

Package idroidgame. activitytest; import Android. App. Activity; import Android. OS. Bundle;Public ClassActivitytest extends activity {/** Called when the activity is first created .*/@ OverridePublic VoidOncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. Main );}@ OverrideProtected VoidOnstart (){// Todo auto-generated method stubSuper. onstart ();}}

Add other methods to be overwritten, and so on.

onresume () and onpause: When the Program loses focus or is disabled, the onpause () of the activity will be promoted (); when the program is awakened again, it will trigger onresume (). Therefore, in the process of processing a program, when temporarily leaving an activity or service, it should be processed in onpause. Take a download program as an example. If you want to pause the download, You can process it in onpause. If you want to continue, you can proceed in onresume.

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.