user913240
user913240

Reputation: 313

Android app name not being displayed

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> 

Upvotes: 28

Views: 41716

Answers (13)

mohsen
mohsen

Reputation: 51

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");

Upvotes: 2

Lautaro
Lautaro

Reputation: 61

I have the same problem, solution for me:

on MainActivity.java change:

public class MainActivity extends Activity {...}

for

public class MainActivity extends AppCompatActivity {...}

Upvotes: 6

Murugesan
Murugesan

Reputation: 43

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>

Upvotes: 1

F J Patil
F J Patil

Reputation: 59

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>

Upvotes: 1

Prashant Sushir
Prashant Sushir

Reputation: 181

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.

Upvotes: 2

ssrp
ssrp

Reputation: 1266

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>

Upvotes: 1

Dori
Dori

Reputation: 18403

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!

Upvotes: 4

diadyne
diadyne

Reputation: 4118

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.

Upvotes: 23

Shah
Shah

Reputation: 5020

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

Upvotes: 0

Chandan Adiga
Chandan Adiga

Reputation: 576

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

Upvotes: 3

ranganath.tm
ranganath.tm

Reputation: 93

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

Upvotes: -1

blessanm86
blessanm86

Reputation: 31779

You should replace

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

with

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

Upvotes: 1

Ryan Amaral
Ryan Amaral

Reputation: 4279

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.

Upvotes: 8

Related Questions