Android-activity startup process

Source: Internet
Author: User

android-activity startup Process

An Activity

Official definition: Activity is an important component of the interactive interface that Android applications provide

Add: Activity is a business class that is the foundation of the interface memory business behavior that hosts the application, including Ui,service, etc.


Two activation process of activity
1 Create a new activity class inheriting from the system activity class and defining attributes and internal methods


2 Register the Activity class within the manifest file:
<activity android:name= ". Activity1 ">
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
The above code is the activity class for the system to start by default, note name= ". Activity1 "before adding.
And the class name is the same as the activity name created, and the system cannot start if an error occurs
An application can have only one activity class that is started by default, which adds <action> and <category> two rows of activity

3 overriding the Parent class function oncreate () implementation

4 the definition of the interface->layout the XML file related to this activity class in its own definition:
Layout file naming all lowercase

5 interface bindings, Setcontentview (R.layout.***.xml) in the new Activity class


Kernel mechanism of three startactivity

StartActivity ()

Startactivityforresult (Intent,-1)

Execstartactivity (...) -

Activitymanagernative.getdefault (). StartActivity (...)

Note that Getdefault () implements the Iactivitymanager interface, which uses the system's services to start the Activitymanager interface.




Android-activity startup process

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.