Android registration file androidmainifest. xml explanation

Source: Internet
Author: User

Activity is an application component that provides users with a visual interface for convenient operations, such as calling, taking photos, sending emails or browsing maps. Each activity provides a visual window, which overwrites the entire screen, however, in some cases, some smaller windows may float on another window.

1. Create an activity

Import android. app. activity; import android. OS. bundle; public class mainactivity extends activity {@ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // use setcontentview to display setcontentview (R. layout. main );}}

2. register the above activity in the androidmainifest. xml file

<? XML version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: Android = "http://schemas.android.com/apk/res/android" package = "com. ljq. activity "Android: versioncode =" 1 "Android: versionname =" 1.0 "> <application Android: icon =" @ drawable/icon "Android: label = "@ string/app_name"> <! --. Indicates that mainactivity is the class under com. ljq. Activity of the current package. If the class is in the current package of the application, the dot symbol can be omitted. If the class must be added under the application's sub-package, for example, the mainactivity class is in COM. ljq. activity. the user package can be written as follows: <activity Android: Name = ". user. mainactivity "/> --> <activity Android: Name = ". mainactivity "Android: Label =" @ string/app_name "> <! -- 1. An application can have multiple activities, with each activity at the same level. Which activity is the first to start when the program is started? Some programs may need to be displayed in the program list, while others do not. How to define it? Android. intent. action. main determines the activity android that the application starts first. intent. category. launcher determines whether the application is displayed in the program list. 2. Because your program may have many activities, as long as the xml configuration file contains such an intent-filter, and this launcher exists in it, this activity is the first activity to run when you click a program. 3. Now there is only one activity, so adding or not adding does not matter. The activity that is enabled by default when the simulator is started. --> <Intent-filter> <action Android: Name = "android. intent. action. main "/> <category Android: Name =" android. intent. category. launcher "/> </intent-filter> </activity> </Application> <uses-SDK Android: minsdkversion =" 7 "/> </manifest>

Address: http://www.cnblogs.com/linjiqin/archive/2011/06/03/2070578.html

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.