Alex Rivera | Logout

What's the "dot" for when registering an Activity

Asked 2011-01-28T23:48:24.730
58

I'm kind of a noob at programming for the Android OS. I noticed in the books I have been reading that the authors have placed a "dot" in front of the activity name when registering their activities in the manifest. I've looked around the Android developer site and I can't figure out why we need the "dot". Does the "dot" actually server a purpose? Do I need it? I have included an example below. Notice the "dot" before "NewActivity":

<activity android:name=".NewActivity"></activity>
Edit
Report

1 Answer

32

http://developer.android.com/guide/topics/manifest/activity-element.html#nm

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 <manifest>.

So given ApplicationManifest.xml:

<manifest 
    ...
    package="com.stackoverflow.android.geotask"
    ...>
    <application ...>
        <activity android:name=".view.TaskListListView" ...>
        ...
    </application>
</manifest> 

then since android:name=".view.TaskListListView" has a leading period, so it is interpreted as android:name="com.stackoverflow.android.geotask.view.TaskListListView".

answered 2011-01-29T00:07:05.773

Your Answer