This question already has answers here:
How to set different label for launcher rather than activity title?
(8 answers)
Closed 10 years ago.
So I've got an Android App with an generated Login Screen (the one you can directly create from Eclipse). That's working.
The problem is this:
I've set the Login screen to be the Launcher activity. This works. Unfortunately the App is then called as the label parameter of the login activity. Meaning the android:label value of the application is simply ignored.
Here's my code as my question sounds quite vague:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" <!-- the app name i want it to have -->
android:theme="#style/AppTheme" >
<activity
android:name="com.test.testytest.MainActivity"
android:configChanges="orientation"
android:label="#string/app_name" >
</activity>
<!-- some more activities -->
<activity
android:name="com.test.testytest.LoginActivity"
android:label="#string/title_activity_login" <!-- the name the app is called in the drawer etc. -->
android:windowSoftInputMode="adjustResize|stateVisible" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
strings.xml:
<string name="app_name">Testy Test!</string>
strings_activity_login:
<string name="title_activity_login">Sign in</string>
When I change the string of the Login activity to app_name, the name of the app changes, too. But I'm quite sure that the app should be called as defined in android:label in
Hope you can help me or point me to my mistake (maybe I'm just missing a little detail).
A little Edit: I don't want to change the label of my Login activity as it should remain "Login". And it also should stay the first activity to be called. But the App Name in the drawer should be the one defined in .
Thanks to Geobits:
Here's the solution How to set different label for launcher rather than activity title?
Solution found!
Apparently the "intent-filter" can have a label attribute. If it's absent
the label is inherited from the parent component (either Activity or
Application). So using this, you can set a label for the launcher
icon, while still having the Activity with it's own title.
http://developer.android.com/guide/topics/manifest/intent-filter-element.html
android:label="#string/title_home_activity"
android:icon="#drawable/icon">
Related
note: I read the former post about changing app name. The label of my app should be correct, still it is not.
I have an android app that I made.
It consists of different activities.
But when I downloaded my app, it is called "Sign in". This should not be the case, I want it to be called something else. How can I achieve this?
Here is my manifest file:
....
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and my strings file:
<resources>
<string name="app_name">Exigentia</string>
<string name="action_settings">Settings</string>
<string name="EmergencyButton">EmergencyButton</string>
<string name="title_activity_login">Sign in</string>
<!-- Strings related to login -->
<string name="prompt_email">Email</string>
<string name="prompt_password">Password (optional)</string>
<string name="action_sign_in">Sign in or register</string>
<string name="action_sign_in_short">Sign in</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email
completions."
</string>
</resources>
So why does my app display "Sign in" as its name, and not Exigentia?
Note: this is before I click my app and launch it. Once it is launched, the sign in should be there in the top
According to the App Manifest's <activity> label attribute:
A user-readable label for the activity. The label is displayed on-screen when the activity must be represented to the user. It's often displayed along with the activity icon.
If this attribute is not set, the label set for the application as a whole is used instead (see the <application> element's label attribute).
An application can have multiple entry points represented by multiple activites. For example, you want to create an application that has both a teacher and a student entry points on the user's phone without requiring them to install multiple apps. This also means that you can assign different labels to the activites, like Teacher and Student, respectively.
Basically, when you create an app with a single main Activity, you just place the app name on the <application> tag and the icon in the main menu will have that label. Obviously for multiple Activity entry points this would not be great, so you have the option to override it one-by-one.
I think you want to achieve that the label be displayed on the app bar (action bar, toolbar, you name it). This should be done by either putting the label onto the app bar in the layout XML or using code, such as getSupportActionBar().setTitle(R.string.title_activity_login);.
Do you have translations in your app? This could be the problem because android displays the local strings if exists. If you have translations, make sure you have changed the app_name string in all strings.xml files. Guaranteed way to make sure if you have translations is that go to your project directory and see if there are multiple "values" folders under "...\app\src\main\res" like "values-en", "values-de" etc.
No need to put label in all activity Tags. Try below one:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I wanted to start a different activity from my app first, so I moved:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
This led to an odd (but interesting problem), the name of my app (shown on home screen) has completely changed to the name of the activity that I am calling first. The thing is, I already have the name of the app declared up in the application tag:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="This should be the title, right?"
android:theme="#style/AppTheme" >
But the activity that is starting first is still the name of my app now. I have researched this thoroughly, but the only results were about how to change the name of your app,(example) which is like this:
android:label="This should be the title, right?"
But that's the strange part, as I already have that set, **yet ** the name of the app is still the name of the activity that is launching first. I would love to understand why that is happening, and how to fix this unexpected issue.
Thanks for the expert advice,
Rich
Here is my entire manifest:
https://gist.github.com/anonymous/12cd29ad7ea9b2206a2b
The caption used for the launcher icon can be driven by:
a label on the <intent-filter>, which you don't have
a label on the <activity>
a label on the <application>
So, if you have an android:label attribute on the <activity> that now has your MAIN/LAUNCHER <intent-filter>, confirm that it is what you want.
Also, home screen launchers can get a little weird at times, due to caching and such, and so a reboot of the device or emulator may be necessary.
The launcher icon will use the label of whatever activity the launcher intent-filter is in. If you want to change the title displayed in the action bar, you can call setTitle() on your Activity at runtime.
I have an Android application with a default activity which is defined in the AndroidManifest.xml:
<application
android:label="NameOfMyApp"
...
<activity
android:name=".LoginActivity"
android:label="Login">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.rei0d.wop.MainActivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
It seems that android:label="NameOfMyApp" will be overwritten if there is an attribut android:label for the default activity.
So I want to change the application's name to something else than Login, NameOfMyApp for example, without changing the android:label of the Login activity. Is this possible? Or do I have to create a blanc activity as default activity which starts the Login activity?
Well, there are multiple possibilities to fix this issue, unfortunately some of them don’t work on all devices.
It seems like that the Launcher takes the application-name from the label of the "Entry Activity". You can prevent his by adding the following attribute to your intent-filer:
<intent-filter android:label="NameOfMyApp">
Unfortunately some Launchers may ignore this, so I wouldn’t go for this solution.
I would recommend you to change the title of your Login-Activity programatically. So first of all change the android:label value of your .LoginActivity to the name of your app.
In onCreate or somewhere else set the title (assuming that you’re using the ActionBar).
getActionBar().setTitle("Login");
Note: You should get the title from a strings-xml file of course
This question already has answers here:
Android app name not being displayed
(13 answers)
Closed 9 years ago.
There where some similar questions around here but my problem is a bit different. I use a label for an activity to be displayed and the system automatically uses that text as the app name which is seen under the app icon in the launcher. BUT I have already set the app name, as u can see in that manifest code:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".OneActivity"
android:label="Project 51" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
what am I doing wrong?
Your code looks like it should work as intended (unless app_name in strings.xml is actually set to "Project 51"). All I can think of is give the intent-filter the label of the application and see if that helps.
I have an Android App with 2 activities. I have the following in the AndroidManifest:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:debuggable="false">
<activity android:name=".MyCellTracker" android:label="#string/activity1_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DisplaySuccess" android:label="#string/activity2_name"></activity>
The activities are properly named, yet the application is using the project name rather than the android:label (#string/app_name) I have given it. If I go to delete the application, then I see that it is named using the android:label. Why is the name that is displayed under the icon on the program launcher not using android:label in the application node?
This may not be the answer you're looking for, but you can set the activity title using setTitle(string title).
Set the title programmatically, and set the app title in the manifest.xml using the main activity's label.
According to that reference:
http://developer.android.com/guide/topics/manifest/activity-element.html#label
it is the label of the main activity. However if you don't set a label in the activity, the label of the application is taken.