Monday, 7 March 2011

How to change the name of the application - Android

Sometimes, the name of an application should be changed after the program is created. Then several place should be modified. In this example I am going to modify the old app name "oldName" to the new app name "newName"

1. Change the value of app_name
1.1 Open the file in the res/strings.xml
1.2 Inside of the tag  <string name="app_name"> change "oldName" to "newName"
This will change the name showed as title of the application. If you want to a cleaner change, continue. Otherwise, it should be enough to change the name of the application for the users
Optional: Change also the tag <resources> <string name="hello">. It will affect the demo showed at beginning.

2. Change the name in the AndroidManifest.xml
2.1 Open the AndroidManifest.xml
2.2 Find the xml tag called: activity with an action called android.intent.action.MAIN. More or less like this:

<activity android:name=".oldName" android:label="@string/app_name">
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

2.3 Modify the tag "android:name" from ".oldName" to ".newName".

3. Change the name of the java file
3.1 Right click on the java file and choose Refactor -> Rename
3.2 Change "OldName" by "NewName" and press "Finish"

If you want to know how to change also the name of the package, see this post:

No comments:

Post a Comment