28
votes

My Android app is not displaying the application name "app_name", instead its displaying the activity name "title". This is from my manifest file;

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

Why is the application getting its name from the Main activity and ignoring the Application label?

This is the full manifest

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.extempor.cheetah"
     android:versionCode="1"
     android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".Main"
              android:label="@string/title">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".InfoHelp"
              android:label="@string/titleInfo">
        <intent-filter>
            <action android:name="android.intent.action.HELPINFO" />
            <category android:name="android.intent.category.DEFAULT" />

        </intent-filter>
    </activity>
    </application>
    <uses-sdk android:minSdkVersion="10" />

<uses-permission android:name="android.permission.INTERNET" />

    </manifest> 
13
add you full code of menifest fileNiranj Patel
I think you should check this post. It is the right way to the solution.Vivek Todi

13 Answers

23
votes

This question explained the reason for this to me:

Naming my application in android

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.

7
votes

You can only display one label at a time. Application label or Activity label.

If you set a label and run an activity, you will see the Activity label.

To see Application label, doesn't set android:label="@string/title" on Main activity.

6
votes

I have the same problem, solution for me:

on MainActivity.java change:

public class MainActivity extends Activity {...}

for

public class MainActivity extends AppCompatActivity {...}
4
votes

You can just set your launcher activitys label as the app name and then set the actionBar title manually in code for that activity

getSupportActionBar().setTitle(R.string.title_user_login);

This is of course if you are using an action bar. Normal activity title headings are ugly anyway!

EDIT: saying that you can see the text change on start up!

3
votes

Even I noticed the same and seems that is a bug! You should report it to google :)

2
votes

If you or somebody is still facing the problem then here is the solution which worked for me.

Keep the Application label and Main activity label same in manifest as shown below

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

in main.java file set the label of your activity as shown below (I guess you are using action bar)

ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(getResources().getString(R.string.title));

before installing this changed app, uninstall the previous version reboot your phone and now install the changed app.

I hope this helps.

2
votes

you need

public class MainActivity extends AppCompatActivity {.....}

if you can't extend AppCompatActivity, then you can alternatively add the last line of the code below to show a title in the bar..

   protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle("the name i want to appear");
1
votes

You should replace

<activity android:name=".Main"
          android:label="@string/title">

with

<activity android:name=".Main"
          android:label="@string/app_name">
1
votes

Use

this.setTitle("");

in your onCreate() method of your activity and use your prefered application name in the @string/app_name for

<application> android:lable = "@string/app_name" </application>
1
votes

If you are using Android studio, then you you should extend AppCompatActivity then only the Activity will be displayed.

Example Code: Main Activity: public class MainActivity extends AppCompatActivity

Styles.XML

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

1
votes

If you are using Android studio, also you are using MapsActivity then you should extend ActionBarActivity, also put app name at String.xml. It's works for me. thanks

<resources>
<string name="app_name">App Name</string>
<string name="title_activity_maps">Map</string>

0
votes

In all activities you should change the value of

 android:label 

to

 "@string/app_name"

UPDATED:

well the answer is that The First Activity with the label @string/title is your main activity which comes on the Launcher menu . So you have to set the label to that activity. Other Solution is that You create a Temp Activity and Call you Main Activity from there and set Your Main Activity the title Label and your Temp activity the App_name label and make your Temp Activity the Main Launcher.

Hope this Helps

Thanks

-1
votes

You can directly give yours Application name to it like android:lable="app_name" or check yours String.xml file in Values folder