Setting two different labels for the Launcher and the first activity - android

This should be a simple fix. My problem is that my launcher name is the same as my first activity. #string/app_name is my actual application name that I want it to show, but it is showing my first activity "Drafts" for the launcher. If I take out the #string/activity_drafts then the Launcher is correct, but then the first activity is my app_name which is not the behaviour I am looking for. I just want two seperate names for the launcher and the first activity's title and I'm not really sure what is going on here.
Manifest.xml
<application android:name="com.jordan.dictation.Dictation2Go"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/dp_launcher2"
android:logo="#drawable/dp_white_logo"
android:label="#string/app_name"
android:theme="#style/MyTheme">
<activity
android:name="com.jordan.dictation.Draft_Activity"
android:screenOrientation="portrait"
android:label="#string/activity_drafts"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

I am not sure how to do it in manifest file, however you can do it programmatically in your activity:
setTitle("Activity title");
or
getActionBar().setTitle("Activity title");
EDIT: GOT IT!
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
<activity
android:name="com.example.so1.MainActivity"
android:label="ACTIVITY NAME"
>
<intent-filter android:label="APP NAME">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Note: Doing this might result in unexpected behavior upon device restart, e.g. with an unmodified Samsung S3, a shortcut on the home screen will be renamed to the activity's label. (See https://stackoverflow.com/a/7250902)

The icon and label set for an intent filter are used to
represent a component whenever the component is
presented to the user as fulfilling the function advertised
by the filter. For example, a filter with
" android.intent.action.MAIN " and
" android.intent.category.LAUNCHER " settings
advertises an activity as one that initiates an
application — that is, as one that should be displayed in
the application launcher. The icon and label set in the
filter are therefore the ones displayed in the launcher.

Related

Activity label appears on home screen instead of app name

In AndroidManifest.xml, the application tag has:
android:label="#string/app_name"
and app_name in res/values/strings.xml reads "My App".
But after running or debugging on both the emulator and an attached device, the app icon on the home screen displays the main activity's label instead of the app label. Is this expected behavior, and if not why might it be happening?
Yes it is Expected behavior. The app name will be seen in the applications tab in settings. The main screen displays the launcher activity's label.
If you want to display the app_name property as the label of your application below the launcher icon you can specify the android:label property in the application tag of your android manifest file.
For example:
<application
android:name=".MyApp"
android:icon="#drawable/myIcon"
android:label="#string/app_name">
A workaround for this behaviour:
In manifest:
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In MainActivity's onCreate:
getSupportActionBar().setTitle(R.string.activity_name);
By doing this, the app name will appear on home screen, and you can still have a different title for your launcher activity.
People see here, I got the same issue and finally resolve it.
Launcher show only the mainActivity because activity label is preferred for Phone Launcher.
So one want show Application labe rather than MainActivity's, he should delete the line:
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
delete this:
android:label="#string/title_activity_main"

Can I set the name of the app to something other than the label of the activity with the intent-filter?

I have an app with four activities. I have set the intent-filter on one of them so it will be displayed first to the user when he starts the app. It has a label that says "Add expense".
Now the name under the icon for the app in the phone says "Add expense".
I would like the activities to have their different labels because they are displayed in the menu at the top of each activity and help the user understand what the activity is about. But I want the app name to be something other than the label of the activity with the intent-filter.
Is that possible?
Part of my manifest:
As you can see I've tried to set android:label="#string/app_name" on the application level but that doesn't work. The label on the activity is displayed under the icon anyway.
<application
android:icon="#drawable/ic_money_bag"
android:label="#string/app_name"
android:theme="#android:style/Theme.Holo.Light" >
<activity
android:name=".AddExpenseActivity"
android:label="#string/add_expense_header" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListExpensesActivity"
android:label="#string/list_expenses_header" >
</activity>
<activity
android:name=".AddExpenseAccountActivity"
android:label="#string/add_expense_account_header" />
<activity
android:name=".ListExpenseAccountsActivity"
android:label="#string/list_expense_accounts_header" />
</application>
Regards,
Mattias
You can use setTitle(String s) in each activity to change the name that appears in the title bar dynamically. So for you setting it in onCreate to whatever you want might suffice.
setTitle("Hello StackOverflow");
Try giving
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
When the label is specified for the activity then i will be shown with the same label in Launcher
What can u do is give label to intent-filter

Difference between Category Home and Category Launcher

I am not clear about what is the difference between category home and category launcher. From Android documentation page:
CATEGORY_HOME : This is the home activity, that is the first activity
that is displayed when the device boots.
CATEGORY_LAUNCHER : Should be displayed in the top-level launcher.
To test the difference I made a simple app with this manifest:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".IntentCategoriesActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Second"
android:label="Whatever" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
</activity>
</application>
But all I see is my launcher activity not the second activity.
Can somebody please explain what am I missing? Thanks.
android.intent.category.HOME is used for Home Screen activities like ADW Launcher, Launcher Pro, etc. If you want to create a new home screen use this.
android.intent.category.LAUNCHER is used to specify which of your activities can be launched. I.e. which ones show up in the app drawer.
android.intent.category.HOME - To be a launcher - this activity is homescreen
android.intent.category.LAUNCHER - To be in launcher - this activity is visible in menu
In one manifest file ,there is only the first main is useful ,the second android.intent.action.MAIN is useless.

How to name Android Application

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.

Android Marketplace icon

This is probably a dumb question but I can't find it anywhere... Which icon is used in your marketplace listing? Is it always the application android:icon="#drawable/icon" setting from your manifest file or can you have a launch icon different from your marketplace listing?
Android Market uses application icon, but you can have different launch icon if you assign another one to your default (starting) activity.
https://developer.android.com/guide/topics/manifest/application-element.html#icon
https://developer.android.com/guide/topics/manifest/activity-element.html#icon
I think an example will do:
// app-wide, incl. Android Market
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
>
// launcher only
<activity android:name=".activity.Launcher"
android:label="#string/launcher_title"
android:icon="#drawable/launcher_icon"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources