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"
Related
I have the following manifest:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="#style/AppTheme"
<activity
android:name=".LoginActivity" android:launchMode="singleTask" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity" android:screenOrientation="portrait"/>
<activity android:name=".TaskDetailActivity" android:screenOrientation="portrait"/>
<activity android:name=".ConfigurationActivity" android:screenOrientation="portrait"/>
</application>
I don't know why, if I minimize the application and then i click on application icon, the app get relaunched instead of going to the last activity.
If I use application switcher instead of application icon for opening the application, It goes back to the last activity on use, so it works as expected.
Why is this behavior? I want to open the last activity when I click on application icon not restart the whole application.
An Activity with singleTask launchMode is allowed to have only one instance in the system.
Remove android:launchMode="singleTask" for more about singletask
I have an application that works like the UBER, it happens that when you're going on a run, the screen where the passenger accompanies the driver moving up to him, when the user will open other applications and attempt to return to the app by clicking on the main icon of the application that is in the launcher, the application returns to the first screen and not to the screen that was previously being screen is lost ...
My manifest.
<application
android:name=".Application"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:screenOrientation="portrait"
>
<activity
android:name=".MainActivity"
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=".ui.RaceActivity" android:screenOrientation="portrait"></activity>
</application>
It is because you had used finish() in your java coding as i know if you use finish() for activity then it always finish your activity and when you will open app then it will start it from first screen .
When i use the Label attribute in the manifest for an activity, it does not show in the recent application list. Code for activity in manifest file is:
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="#style/MyTheme"
android:icon="#drawable/ic_launcher"
android:label=""
>
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
when i use android:label="#string/app_name" , then it start showing in the recent tab, but i dont want activity label.
Your application is not visible in recent apps list because label of your main activity is empty.
Change
<activity... android:label="">
To
<activity... android:label="#string/some_name">
Edit:
If you don't want to show label for your activity then do the following.
You must set android:label="#string/some_name" in <activity> tag
And then write getActionBar().setDisplayShowTitleEnabled(false); in onCreate() method of your activity you want to hide label of.
This will let you hide the activity label and will show your app in recent apps list as well.
I have a manifest with its label declared so the launcher label is different from the Main Activity (the one that is launched at start).
It was working fine, but today I saw on a friends phone it took the activity's label instead.
I have no idea what could be happening.
If it is of any help, the phone was a Motorola Razr.
Here's the relevant portion of the manifest:
<application
android:name="com.app.eventiame.EventiameApp"
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock.Light.DarkActionBar" >
<activity
android:name="com.app.eventiame.MainActivity"
android:label="#string/title_activity_main" >
<intent-filter android:label="#string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You have wrote
android:name="com.app.eventiame.EventiameApp"
instead you can just specify your app name here as below
android:name="EventiameApp"
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.