Peter
Peter

Reputation: 1759

Change application's name without touching the default activity

I have an Android application with a default activity which is defined in the AndroidManifest.xml:

<application
    android:label="NameOfMyApp"
    ...

    <activity
                android:name=".LoginActivity"
                android:label="Login">
                <meta-data
                    android:name="android.support.PARENT_ACTIVITY"
                    android:value="com.rei0d.wop.MainActivity" />
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    </activity>
</application>

It seems that android:label="NameOfMyApp" will be overwritten if there is an attribut android:label for the default activity.

So I want to change the application's name to something else than Login, NameOfMyApp for example, without changing the android:label of the Login activity. Is this possible? Or do I have to create a blanc activity as default activity which starts the Login activity?

Upvotes: 0

Views: 69

Answers (1)

reVerse
reVerse

Reputation: 35264

Well, there are multiple possibilities to fix this issue, unfortunately some of them don’t work on all devices. It seems like that the Launcher takes the application-name from the label of the "Entry Activity". You can prevent his by adding the following attribute to your intent-filer:

<intent-filter android:label="NameOfMyApp">

Unfortunately some Launchers may ignore this, so I wouldn’t go for this solution.

I would recommend you to change the title of your Login-Activity programatically. So first of all change the android:label value of your .LoginActivity to the name of your app. In onCreate or somewhere else set the title (assuming that you’re using the ActionBar).

getActionBar().setTitle("Login");

Note: You should get the title from a strings-xml file of course

Upvotes: 1

Related Questions