Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Application Name Appears as Activity Name

Tags:

android

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?

like image 639
Androider Avatar asked Mar 22 '11 20:03

Androider


2 Answers

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.

like image 162
Patrick Avatar answered Sep 22 '22 20:09

Patrick


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.

like image 39
Brian Cooley Avatar answered Sep 24 '22 20:09

Brian Cooley