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