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?
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.
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.
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!
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".
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();
}
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
Related
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 am new to the android as a programmer.In the android manifest file we have the code as:
<activity
android:name".Class1"
android:label="Myapp">
<intent-filter>
<action android:name="android.intent.action.MAIN/>
<category android:name="android.intent.category.LAUNCHER/>
</intent-filter>
</activity>
Question
Why do we need to specify the category LAUNCHER, when we have specified the action to be MAIN which is enough to tell the android that Class1 is going to be initial activity of my app?
ACTION_MAIN is required Action to be performed.It is the main or starting point and wont expect any data.
CATEGORY_LAUNCHER The activity is the initial activity of a task and is listed in the system's application launcher.
You could refer these links
http://developer.android.com/reference/android/content/Intent.html
What is the meaning of android.intent.action.MAIN?
"android.intent.category.LAUNCHER" means this activity will display an icon in the launcher home screen. Without this category , you can't see its icon in launcher home screen.
android.intent.action.MAIN means this activity is a entry point of your app.
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
Hey in the Launcher code I want one app to be shown on homescreen , in AndroidManifest.xml. I wrote these lines :
<activity
android:name=".MyAppTabs"
android:theme="#android:style/Theme.NoTitleBar"
android:label="MyApp"
android:icon="#drawable/ic_launcher_app">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
on adding these lines I am getting my app on the homescreen but it is not launching, but using Menu option I am able to launch my app...Any help??
Adiing more details.. I have default_workspace.xml file in xml folder where I am adding my app to favorite tag...
<favorite
launcher:packageName="com.android.launcher"
launcher:className="com.android.launcher.apps.MyAppTabs"
launcher:screen="3"
launcher:x="3"
launcher:y="0" />
If any other information required ..Please tell me.
This can be acheived only for the applications which is part of the same application (In this case your Launcher).
You should not start the activity of the application which you want to run inside of laucher
You should get the parent view where the applcation wants to be shown,
Get application design as single view or view group, consider this as child (this would be the child of launcher parent view)
Add child apllication view into launcher parent view.
In my manifest file, I have given the application name as MyApp and the name of the starting activity as Main Menu.
<application android:theme="#style/theme" android:icon="#drawable/myicon" android:label="#string/app_name">
<activity android:name=".MainMenu"
android:label="#string/mainmenu_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
When I see the app icon in the default menu screen of android, the name shown is Main Menu. Why is MyApp not the name shown for the app?
Because your app can define more than one activity that shows up in the launcher. All activities that have this type of intent filter:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Will appear in the launcher, each with its own label. The fact that if you don't define a label on your activity, it's inherited from the application is basically a commodity.
Also, every activity has its own android:icon (which, again, is inherited from <application> for commodity). With this property your two launcher entries can have not only different labels, but different icons as well.
On a more general note, even "non-main" activities can handle certain types of events, and in these cases their labels and icons are relevant. For example, if one of your activities (doesn't matter which one) handles ACTION_SEND intents (like most sharing apps do -- see Facebook, Twitter, ...), then whenever the user presses a "Share" button in any application, a list of applications that can complete that certain activity is displayed to the user (in this case these applications could be Facebook, Twitter and your app). This list will contain an icon and a label (i.e. Facebook). Your entry's display will be dictated by the android:icon and android:label attributes defined by your receiving <activity>, and only if it doesn't define them they'll be taken from your <application>.
This allows you to have an entry such as "Share via MyApp" without modifying your application's name. Or, if your application also has an activity that handles ACTION_VIEW, that activity could have, for example, the label "View in MyApp".
Digging even deeper, <intent-filter> elements can have their own label and icon. Basically, Android chooses the icon and label to display like this:
If the <intent-filter> has it, pick that, stop.
If the <activity> has it, pick that, stop.
Pick the one in <application>.
This is helpful in two situations:
You don't want to change your activity's label / icon: maybe you want to use those in other places such as the title bar (and you don't want your title bar to say "Share via MyApp")
You have activities with multiple intent filters. For example, you could handle both ACTION_SEND and ACTION_VIEW intents in the same activity. In this case, you'd have two intent filters set for that activity with the labels "Share via MyApp" and "View in MyApp".
I hope I've made myself clear, these are very basic things that can be pretty hard to grasp at first, but that provide great flexibility in building apps and integrating them with the Android system and/or other apps.
Another thing to note is that you can easily have an application that doesn't have any entries in the launcher (by not having any activity with the intent filter mentioned above). These are perfectly valid apps and it's good practice when creating Service-only apps (such as widgets).
If android:label is set for activity then its value is taken. It it is omitted for activity then the android:label attribute set on application is taken instead.
You simply cannot have different labels for activity and for application as your application has one launcher for your activity with the label you set it to have. I'm not quite sure I totally understand what you are trying to achieve tho.
In the manifest, remove the android:label attribute on the launch activity. Then the activity will inherit the name specified in the application's android:label.