74

I think I'm getting senile because I was convinced that to give a name to your application, you had to fill this part of the manifest:

<application android:icon="@drawable/icon"  android:label="MyApplicationName">

However for a reason I don't understand, my application gets the name of my first activity, in which I load data, thus, it is called "Loading", defined as follows in the manifest:

<activity android:name="AccueilSplash" android:label="Loading">

Any idea why that is?

abatishchev
  • 92,232
  • 78
  • 284
  • 421
Sephy
  • 48,024
  • 30
  • 119
  • 129
  • 1
    Also look at this question, explains how to have a different name for your application in Application drawer, than the activity title. https://stackoverflow.com/questions/3488664/android-launcher-label-vs-activity-title/7250902#7250902 – Neocy Oct 29 '14 at 20:59

3 Answers3

86

The launcher actually shows android:label and android:icon for activity(ies) that declare

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

so application label is of no use.

yanchenko
  • 53,981
  • 33
  • 142
  • 163
  • 44
    Actually the application label is used if your activity doesn't itself have a label. My suggestion is to always set a label and icon on your applications (this will show up in places like manage apps), and only set the label or icon on activities that need to be different than the overall application. – hackbod Mar 15 '10 at 00:12
  • 1
    Right, so if I want a proper name for my app, I need to set my first activity label...That's what I thought. Thx – Sephy Mar 15 '10 at 09:17
  • 2
    Or you can just delete the label for the first activity and use the application label. – shim Nov 02 '12 at 20:37
  • 3
    I think this is [the real solution](http://stackoverflow.com/questions/3488664/android-launcher-label-vs-activity-title) – Vivek Todi Dec 23 '13 at 12:01
  • If android:label is not defined in application tag and its activities then it will pick up package name in title bar of activity.So always define android:label in your application tag . – Arun Kumar Mar 21 '15 at 04:17
  • I've been trying to publish apps on Baidu (which is extremely hard). The site doesn't ask me what the title of the app is, instead, it just sets the title from the `application label` from the manifest unlike Google. – Attacktive Jul 13 '15 at 09:14
13

It is an already known issue of the tool (I suppose you are using eclipse). Google Group - Android Developers.

The Application and the first Activity share the same name specified in the android:label field of the <activity> item.

If you want to use different titles for the launcher in the app list and the first activity, you can choose between these options:

1.a) Set just the Application name in the Manifest.

<application
        android:label="@string/app_name"
        ... >

and don't specify android:label="@string/title_first_activity" for the first Activity. It will inherit the Application label.

OR

1.b) Set the Application name in the android:label field of the first Activity in the Manifest.

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

The <application> item will share the same label of the <activity> item, whether you specify a value for the <application>'s android:label field or not.

The next step is:

2) Set the title for the first Activity at run-time in the FirstActivity.class

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_login);
        setTitle(R.string.title_activity_login);
        //TODO: insert the rest of the code
}

In this way your first Activity will change his title few moments after it will be shown on the screen of your phone.

Re MiDa
  • 189
  • 1
  • 8
3

Are you referring to the title at the top of the screen when you run the application? If so, that title bar shows the label of the current activity I believe.

Matt Swanson
  • 1,164
  • 2
  • 11
  • 28
  • Yeah I know that, this title at the top of each activity can be named by the label as defined hereabove in my manifest. But I'm speaking of the name of the application. Actually, it's the name displayed just below the icon of the application, on the desktop of the phone... – Sephy Mar 14 '10 at 22:53
  • 4
    After doing some testing, I could only get it to work by using an externalized string for the application label. Would yield no change. However Would show whatever I set "app_name" to in the strings.xml – Matt Swanson Mar 14 '10 at 23:02