Androidmanifest.xml add different packages in the component (Activity, service android:name specified value is usually a period plus class name), you can specify the full class name (package name + class name) to resolve

Source: Internet
Author: User

We all know that for multiple activity, if you are in the same package, you can register in Mainfest

XML code
  1. <span style="Font-size:small;" ><? XML version= "1.0" encoding="Utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.trinea.sns.activity"
  4. android:versioncode="1"
  5. android:versionname="1.0">
  6. <uses-sdk android:minsdkversion="3" />
  7. <uses-permission android:name="Android.permission.INTERNET" />
  8. <application android:icon="@drawable/icon" android:label="@string/app_name" >
  9. <activity android:name=". Updatestatusactivity "
  10. android:label="@string/app_name">
  11. <intent-filter>
  12. <action android:name="Android.intent.action.MAIN" />
  13. <category android:name="Android.intent.category.LAUNCHER" />
  14. </intent-filter>
  15. </Activity>
  16. <activity android:name=". Viewsnsactivity "
  17. android:label="@string/app_name">
  18. </Activity>
  19. </Application>
  20. </manifest></span>

The above updatestatusactivity and viewsnsactivity are also defined below the package com.trinea.sns.activity, but if

Updatestatusactivity under the bag com.trinea.sns.activity, and viewsnsactivity under the bag com.trinea.sns.activity2 what to do?

Each activity, service, and other application component will correspond to a <activity>, <service> tag in the Androidmanifest.xml file. There is a required attribute in these tags:android:name, which needs to specify a class name, like the one above. Updatestatusactivity and Android.intent.action.MAIN. Did you find out the difference between the two? The first one is. The way and the second is the full path. There are 3 ways to specify the value of the Android:name property, as follows:

1. Specify the full class name (Packagename+classname), for example, Net.blogjava.mobile.Main.

2. specify only the class name , for example,. Main, where main is preceded by "." is optional. The package name in which the class is located needs to be specified in the <manifest> tag's packages property.

3. specify the relative class name , which is similar to the 2nd way, except that the class name is not specified in the Android:name attribute of the <activity> tag, and there are some package names. For example, if the main class is in the NET.BLOGJAVA.MOBILE.ABCD package, you can specify Net.blogjava.mobile in the Packages property of the <manifest> tag, and then <activity The Android:name property of the > tag is specified in the. Abcd.main.

Thus, the purpose of the package is to make it easier to specify the value of Android:name and other related properties, which is a default packet. If you do not specify a package name in Android:name, the value of the packages attribute is automatically added to the previous

Reference: HTTP://DEVELOPER.ANDROID.COM/GUIDE/TOPICS/MANIFEST/ACTIVITY-ELEMENT.HTML#NM

Androidmanifest.xml add different packages in the component (Activity, service android:name specified value is usually a period plus class name), you can specify the full class name (package name + class name) to resolve

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.