Reputation: 21335
I have reviewed the manifest for application, and under apps launcher it displays as Activity Name rather than its app name? Why is this. I have another application where when I install it, there are 5 entries one for each activity in the application when there should be just one name, that of the app? So when I go to launch it has 5 identically named apps in the launch list. These are named after the app but there is one for each activity. What could be the reason for this?
Upvotes: 28
Views: 27692
Reputation: 11662
For the first issue, you should be aware that in absence of a label on the launching Activity
the name comes from the default label set in the android:label
attribute on the application tag:
<application android:name="ApiDemosApplication"
android:label="@string/activity_sample_code"
android:icon="@drawable/app_sample_code">
If the Activity
has a label, that label will be used instead.
For the second issue, in the manifest, it is likely that all your activities specify an intent filter with an action of android.intent.category.LAUNCHER. For example:
<activity android:name="ApiDemos">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
If you have such intent-filter tags on all activities, you should take out the intent filter tags on all but the Activity
that you want to launch at startup. If this Activity
has a label, it is the label that will be shown along with the launcher icon.
As of 2019/01/03 on API 27+, it appears that the first activity with the LAUNCHER
category will be launched and its label will be associated with the app icon, so it may not be strictly necessary to remove all the redundant intent filters, but I'd do it anyway because it can lead to confusion.
Upvotes: 15
Reputation: 11
As if you want to place a image view in the place of toolbar title. You have to update the label of particular activity in the android manifest as android:label="";
by doing this your activity name won't gets displayed in the toolbar after the image view and please use the following code for setting image view along with navigation icon and no toolbar title.
try {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle("");
if (getSupportActionBar() != null)
getSupportActionBar().setIcon(R.drawable.header_image_wt);
} catch (Exception e) {
e.getMessage();
}
Upvotes: 1
Reputation: 961
Running Android version 4.1.2 the name of the application will be "static" with respect to the label defined in the activity set as main launcher and not overridden in any intent filters
Upvotes: 0
Reputation: 3549
One way to have a different application name (the name that appears under the app icon) and a different name for the activity that is being launched when you tap on the app icon is to explicitly set a different string in the activity's onCreate() method, like this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Do your thing
// ... bla bla bla
getActionBar().setTitle(R.string.activity_title);
}
Hope this helps!
Upvotes: 8
Reputation: 14378
The above accepted answer is wrong. It says,
the name comes from the android:label attribute on the application tag
That's not true. Take the following code for example.
<activity android:name="ApiDemos" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In this code, the app name that shows in the launcher is set by the android:label
attribute in the activity
tag not the application
tag as the above accepted answer says.
To correct the above accepted response, the name shown under the icon in the launcher comes from the android:label
attribute in the entry point activity's activity
tag (the activity tag that contains the DEFAULT
and LAUNCHER
categories) unless you don't specify it there in which case it comes from the android:label
attribute on the application
tag.
Your first issue can be solved by changing the android:label
attribute in your entry point activity's tag.
Upvotes: 46
Reputation: 101
When you create an Activity via Eclipse, the property android:label inside your activity is automatically set to "@string/your_activity_name" in the AndroidManifest.xml. Adding the intent filter to provide a launcher for this activity, your launcher gets the same label as your Activities android:label.
If you want to label the launcher with your application name, you should change the Activities android:label to something like "@string/app_name".
Upvotes: 2