3

What is the difference between these two ways of setting the android:name field?

I seen both type and not sure why they are written these two different ways

one way I see often is (notice the "." between " and "Server"):

  android:name=".Server" 

the other way without the extra "." before the name:

 android:name="Server"

sample xml

  <service
        android:name=".Server"
        android:icon="@drawable/ic_launcher"
        android:label="audioservice"
        android:process=":my_process" >
    </service>

     <activity android:name=".DBView"> 
        <intent-filter >
            <action android:name="com.example.test.DBVIEW"/>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
Kevik
  • 9,181
  • 19
  • 92
  • 148

2 Answers2

4

Look at this.

The name of the Service subclass that implements the service. This should be a fully qualified class name (such as, "com.example.project.RoomService"). However, as a shorthand, if the first character of the name is a period (for example, ".RoomService"), it is appended to the package name specified in the element.

zeyuec
  • 76
  • 3
  • There have always been some weird errors in manifests where using the full path caused a ClassNotFoundException on some versions. 2.3.2 seems to ring a bell. AFAIK, using the dotted short hand always works. – Simon Feb 04 '13 at 18:30
0

android:name The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"), it is appended to the package name specified in the element. Once you publish your application, you should not change this name (unless you've set android:exported="false").

There is no default. The name must be specified.