Naming my application in android

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?


Solution 1:

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.

Solution 2:

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.

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