What is the correct way of adding an activity to AndroidManifest.xml
?
Actually I have seen in many places an activity defined as
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 .
So given ApplicationManifest.xml:
...
then since android:name=".view.TaskListListView" has a leading period, so it is interpreted as android:name="com.stackoverflow.android.geotask.view.TaskListListView".
source
the dot is not necessary but it basically means: the activity class lives in the same package of the app. So, if your app package is: com.your.package then:
So it means this is basically the same thing
To confirm my answer look here at CesarB's answer, I had also fetch the android source coe and I totally agree with him, this is how the name convention work in the AndroidManifest:
We define package at the top under manifest tag for this purpose only that we do not have to declare it again and again if any activity resides it in the same package.We only start writing by dot to know that it belongs to the same package.All the activities residing in the same package will be accessed through this and if you declare new package other than com.example say com.example.sample than you only have to define .sample.YourActivityname.thats it.We do this refer activity from correct package.
hope this will help you.
yes putting the dot is right way.. if you see the eclipse self generated activity it looks like.
<activity
android:name=".MyFirstActivity"
android:label="@string/app_name">
</activity>
so its the right approach, our ide can understand
Using relative paths is fine.
The path is separated by a dot, rather than a slash.
android:name=".one_path_level_down.MainActivity"
android:name=".one_path_level_down.DetailActivity"
The top level is the package level in your manifest file in the "package=". Something like the following:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.myapp1" >
dot means your package name. It's more short type of declaration.
If you define a subclass, as you almost always would for the component classes (Activity, Service, BroadcastReceiver, and ContentProvider), the subclass is declared through a name attribute. The name must include the full package designation. For example, an Service subclass might be declared as follows:
<manifest . . . >
<application . . . >
<service android:name="com.example.project.SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
However, as a shorthand, if the first character of the string is a period, the string is appended to the application's package name (as specified by the element's package attribute). The following assignment is the same as the one above:
<manifest package="com.example.project" . . . >
<application . . . >
<service android:name=".SecretService" . . . >
. . .
</service>
. . .
</application>
</manifest>
When starting a component, Android creates an instance of the named subclass. If a subclass isn't specified, it creates an instance of the base class.
http://developer.android.com/guide/topics/manifest/manifest-intro.html Declaring class names