Activity interview questions, activity questions

Source: Internet
Author: User

Activity interview questions, activity questions
What is Activity?

Activity is one of the four main components of Android. Generally, a user interface corresponds to an Activity. At the same time, Activity is a subclass of Context, and it also implements the Window interface and KeyEvent interface to process the Window-User Interaction Events.

Briefly describe the lifecycle of the Activity

Activity lifecycle can be dividedTypical LifecycleAndLifecycle in case of exceptionsIn two ways.

The typical lifecycle is as follows:

Opening an Activity will call OnCreate-onStart-onResume is called when an Activity is closed.OnPause-onStop-onDestroy is called when a foreground Activity is blocked by a dialog box or overwritten by a translucent or transparent Activity.OnPause, called when you return to the front-endOnResume; called when an Activity is invisible to the visibleOnRestart-onStart-onResume is called when you press the Home Key to return to the desktop.OnPause-onStop; A calls back A'sOnPause, and then callback B'sOnCreate-onStart-onResume, and then call backOnStop; returns data from Activity B to Activity A, and calls back the data of Activity B first.OnPause, and then callback A'sOnRestart-onStart-onResume.onStop - onDestroy;

The lifecycle of an exception is as follows:

In general, there are two situations that cause abnormal Activity destruction. One is caused by horizontal and vertical screen switching, but by insufficient system resources, the Activity with a lower priority is destroyed by the system. If the Activity is configured in the list fileAndroid: configChanges = "orientation | screenSize", the Activity will not be destroyed and rebuilt during landscape/portrait switching. OnlyThe onConfigurationChanged method is executed when the Activity is destroyed.OnPause-onSaveInstanceState-onStop-onDestroy, which will be executed during reconstructiononCreate - onStart - onRestoreInstanceState - onResume 

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.