Add multiple packages to AndroidManifest. xml

Source: Internet
Author: User

The following is a question and answer:
 
Generally, after creating an Android project, AndroidManifest. xml contains the following content:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Manifest xmlns: android = "http://schemas.android.com/apk/res/android"
Package = "com. myactivities"
Android: versionCode = "1"
Android: versionName = "1.0" type = "codeph" text = "/codeph">
<Application android: icon = "@ drawable/icon" android: label = "@ string/app_name">
<Activity android: name = ". ActivityMain"
Android: label = "@ string/app_name">
<Intent-filter>
<Action android: name = "android. intent. action. MAIN"/>
<Category android: name = "android. intent. category. LAUNCHER"/>
</Intent-filter>
</Activity>
</Application>
</Manifest>
You can see a manifest attribute package = "com. myactivities". Multiple newly created activities must be placed in the com. myactivities package. The problem is that if I create another package and create several activity-class files in it, how can these activities be registered in AndroidManifest. xml? What I finally want to achieve is that the activity in com. myactivities jumps to an activity in the new package through intent. How can this be achieved?
---------------------------------------------------------------------
Each Activity, Service, and other application components correspond to a <activity> and <service> tag in the AndroidManifest. xml file. There is a required attribute in these tags: android: name, which requires a class name, such as the net. blogjava. mobile. Main class. The android: name attribute value can be specified in the following three methods: www.2cto.com
1. Specify the full class name (packagename + classname), for example, net. blogjava. mobile. Main.
2. Only specify the class name, for example,. Main. The "." before "Main" is optional. The package name of the class must be specified in the package attribute of the <manifest> label.
3. Specify the relative class name. This method is similar to the 2nd method, but not only specifies the class name but also some package names in the android: name attribute of the <activity> tag. For example, if the Main class is in the net. blogjava. mobile. in the abcd package, you can specify net in the package attribute of the <manifest> label. blogjava. in the <activity> tag's android: name attribute. abcd. main.
It can be seen that the purpose of package is to more easily specify the value of android: name and other related properties, which is a default package. If the package name is not specified in android: name, the package property value is automatically prefixed.

Author: berber78

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.