2

I followed this tutorial on changing the name of my Android Application by changing the field android:labelin the application node of the manifest(AndroidManifest.xml).

application node:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.pps" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

strings.xml - XML file containing the names of the different strings.

<resources>
<string name="app_name">PPS</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main"></string>
</resources>

After completed this task the name still wont show. This is what I see when I run the application and its installed on my testing device.

Application icon only; no name

A weird thing happened when I changed the value of the android:label present in the activity node by adding text to <string name="title_activity_main"></string> , the application seemed to inherit that as its name.Why is this happening? Did I declare something incorrectly? Are some values clashing?

Update:

When I select "Manage Apps" I actually see the name of the application.

enter image description here

Community
  • 1
  • 1
Joel Dean
  • 2,394
  • 5
  • 30
  • 48

3 Answers3

6

Android by default takes the name of the first first activity (android.intent.action.MAIN) as the display name of the app. To set the title for your activity you should make a setTitle() call from within your activity. E.g.

Your manifest looks like this:

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

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

Your activity looks like this:

public class EntryPoint extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setTitle(R.string.title_activity_main);

}

Hope that helped.

iceman
  • 826
  • 13
  • 24
  • 1
    When I use setTitle() there seems to be a delay, thus its after the layout has loaded the title appears. – Joel Dean Oct 25 '12 at 07:24
  • I also have that issue. If you find a workaround let me know. It is noticeable on the emulator, but hardly on a fast device. – iceman Oct 25 '12 at 07:35
1

The thing in your drawer isn't the application, it's the launcher/main activity of your app.

So it's only logical you see the name of that activity (an app can have more activities then one). If you don't want that activity to have a name for some reason, you shouldn't be surprised that it ends up not having one. A name that is.

Probably the best thing to do is 'fix' why you don't want it to have name? Hide it, or something like that.

Nanne
  • 61,952
  • 16
  • 112
  • 157
  • Well, the icon that is used in the drawer is declared in the application node, so I don't find it that logical... – Till Nov 10 '15 at 14:21
  • Having said that, I guess it does make sense, considering that everything stated in the application node is actually just the default for subnodes, so they can or might not be overriden. – Till Nov 10 '15 at 14:44
0

String is empty Here

 <string name="title_activity_main"></string>

Change the above line to

 <string name="title_activity_main">Your Activity Name</string>
Ram kiran
  • 20,129
  • 14
  • 55
  • 74
  • I want it to be empty. I dont want the activity to have a name. – Joel Dean Oct 25 '12 at 06:53
  • When I add the name of my activity there this then becomes the name of my application. – Joel Dean Oct 25 '12 at 06:56
  • If your activity will never have a name, you can use `android:theme="@android:style/Theme.NoTitleBar"` for it, or make your custom theme inherit this. – Adinia Oct 25 '12 at 06:58