28

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> 
user913240
  • 313
  • 1
  • 3
  • 8

13 Answers13

23

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.

Community
  • 1
  • 1
diadyne
  • 4,038
  • 36
  • 28
8

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.

Ryan Amaral
  • 4,059
  • 1
  • 41
  • 39
  • 3
    I assumed that the application label would be the name associated with the application and the activity label would be the label linked to the activity, but when I look at my application in the application menu it shows the activity label. – user913240 Aug 26 '11 at 04:53
6

I have the same problem, solution for me:

on MainActivity.java change:

public class MainActivity extends Activity {...}

for

public class MainActivity extends AppCompatActivity {...}
Lautaro
  • 61
  • 1
  • 1
4

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!

Dori
  • 18,283
  • 17
  • 74
  • 116
3

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

Chandan Adiga
  • 576
  • 4
  • 14
2

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.

Prashant Sushir
  • 181
  • 2
  • 8
2

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");
mohsen
  • 41
  • 3
1

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>
ssrp
  • 1,126
  • 5
  • 17
  • 35
1

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>

F J Patil
  • 59
  • 4
1

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>

Murugesan
  • 43
  • 7
1

You should replace

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

with

<activity android:name=".Main"
          android:label="@string/app_name">
blessanm86
  • 31,439
  • 14
  • 68
  • 79
  • 1
    I dont want the activity to have the same name as the application. I want the application to be called "Cheetah" and I want the label on the main activity to display "Word Puzzle Solutions". The application name should be displayed with the application icon in the application menu. This is not happening, instead the application is displaying the activity name. – user913240 Aug 26 '11 at 05:01
0

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

Shah
  • 4,990
  • 10
  • 48
  • 70
  • Why? If you can have a label for each activity and also a label for the application, why should they all be the same? – user913240 Aug 26 '11 at 05:03
  • Since the status Bar on top changes when the new activity comes on top . so in that case you have to edit the label for each activity with the name you want to put on that particular activity Status bar. – Shah Aug 26 '11 at 05:11
  • Its not the status bar that is the issue, it is displaying the correct information. Its the application menu which has the Icon and the name of the application. But it is not displaying the application label from the manifest, instead its displaying the activity label. – user913240 Aug 26 '11 at 06:53
  • oohh i see.. well in that case.. the answeer is in the update – Shah Aug 26 '11 at 07:05
-1

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

ranganath.tm
  • 93
  • 4
  • 7