I need the following problem to be resolved:
From the UnityPlayerNativeActivity I am starting a standard Android activity (may be mine, may be with an ad from the ad network - nevermind). When the game is being hidden with this activity on top (not the Unity one) by pressing the home button, as a user I have two ways of restoring it:
from the Recently used apps screen - the app is being restored to the same state, when it was minimized (that is what I expect to happen);
from the launcher, what causes the game's UnityPlayerNativeActivity is being restored with losing all other activities, that have been opened on top of it.
These activities are lost somehow (in a way I don't exactly know, what has happened with them). My game's logic depends on the result of the processes happening there, ie. I need to know, that this particular activity has been exited in any specific way (give a callback for example).
Do you know how I can bring this Unity activity back from launcher with all activities above it, as it was while minimizing it?
I want to understand the difference between the ways of restoring the app from Recently used screen and the launcher. I guess it is related to the intent-filter section within AndroidManifest.xml file, which is included within UnityPlayerNativeActivity entry.
The solution turned out to be quite simple, but not so obvious.
It has turned out, that the AndroidManifest.xml configuration that is being produced by Unity by default is causing this problem. For the main activity that is being started from launcher the following parameters are defined (taken from decompiled app):
<activity
android:alwaysRetainTaskState="true"
android:clearTaskOnLaunch="true"
android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:label="#string/app_name"
android:launchMode="singleTask"
android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:screenOrientation="fullSensor"
launchMode="singleTask">
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
</activity>
The problematic behaviour is being caused by these 2 parameters:
android:clearTaskOnLaunch="true"
android:launchMode="singleTask"
When the I change them to:
android:clearTaskOnLaunch="false"
android:launchMode="standard"
Then the app is resuming fine from the launcher.
The correct parameters should be set as follows:
<activity
android:alwaysRetainTaskState="true"
android:clearTaskOnLaunch="false"
android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:label="#string/app_name"
android:launchMode="standard"
android:name="com.unity3d.player.UnityPlayerNativeActivity"
android:screenOrientation="fullSensor"
launchMode="standard">
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter>
</activity>
Note: While I am able to set the value android:clearTaskOnLaunch="false" for this activity explicitly, the launchMode parameter will be forced by Unity3d and set to "singleTask". I managed to change and check it by decompiling the app and rebuilding from these changed resources. I wonder if there is any elegant way to set this value.
You may find this blog post useful:
http://inthecheesefactory.com/blog/understand-android-activity-launchmode/en
The DevGuide on the application element's android:label:
A user-readable label for the application as a whole, and a default label for each of the application's components.
Yet, there's a world of example manifests that have the form
<application ... android:label="#string/app_name">
<activity ... android:label="#string/app_name"> ... </activity>
<activity ... android:label="#string/app_name"> ... </activity>
...
</application>
Every single Android book I have does this, including the Commonsware books. A glance through the SDK examples shows that ContactManager does this, but not Snake or Lunar Lander.
Is there some historical reason for the attribute to be duplicated like this? Or is it, like Eclipse's stub comments that people leave in post-stub code (and book examples, in one case), or like the duplicate labels in my own imitative manifests, just something that people don't think about?
i think the activity tag with the attribute android:label is not necessary, except you want make the activity the title different with the application label, you can use your own label. the default should be as same as the application label.
A single App can have more than on icon in the Android Launcher as each icon can map to a single activity. A activity with below intent filter will be show as a standalone icon in launcher
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
The value of android:label will be shown as the name under that icon in lancher
No AndroidManifest.xml of the API 2 (Android 1.1) SDK samples has this redundancy. I conclude that it was never necessary, and that it's a (harmless) example of cargo-cult programming.
In some modified version(for example, CM7), you can long press the shortcut to rename it.
But CM7 have some bugs now.
I would like to know is there a way I can do that? modify the database, change the programs code or resources is OK. Thanks.
You need to change AndroidManifest.xml file. You should find the activity that is launched by this icon and change android:label value there. This will change the icon name in Application Launcher and on Home Screen.
It should looks something like this:
<activity android:name=".HelloWorld" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The activity definition in AndroidManifest.xml should contain MAIN and LAUNCHER in its intent filter (otherwise the activity will not be visible in Application Launcher).
Is there a way to change the name (Launcher App Label) of an app without creating a new project?
Note: Name of the App and The label shown on the Launcher Icon on Home Screen on Mobiles can be different.
Example: On the home page in my Mobile where my apps are, I have an icon and the name Foo, but I want to change the name to Bar. Can I do this?
Yes you can. By changing the android:label field in your application node in AndroidManifest.xml.
Note: If you have added a Splash Screen and added
<activity
android:name=".SplashActivity"
android:label="#string/title_activity_splash_screen"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
to your Splash Screen, then the Launcher Icon name will be changed to the name of your Splash Screen Class name.
Please make sure that you change label:
android:label="#string/title_activity_splash_screen"
in your Splash Screen activity in your strings.xml file. It can be found in Res -> Values -> strings.xml
See more here.
There's the android:label for the application, and the android:label for the launch activity. The former is what you see under Settings -> Applications -> Manage Applications on your device. The latter is what you see under Applications, and by extension in any shortcut to your application, e.g.
<application
android:label="#string/turns_up_in_manage_apps" >
<activity
android:name=".MainActivity"
android:label="#string/turns_up_in_shortcuts" >
...
</activity>
</application>
This is a simple thing in Android Studio,
go to: res folder -> values -> strings.xml
change the app_name (in the bellow example:MitsuhoSdn Bhd) to any new name you want.
<string name="app_name">MitsuhoSdn Bhd</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
I noticed there are some differences in how the app name can turn up in Lollipop devices. Before Lollipop, you can have different app names with this:
<application
android:label="#string/app_name"> // appears in manage app info
<activity
android:name=".MainActivity"
android:label="#string/action_bar_title"> // appears in actionbar title
<intent-filter android:label="#string/name_in_icon_launcher"> // appears in icon launcher
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
...
In Lollipop, it will be like this:
<application
android:label="#string/name_in_manage_app_info">
<activity
android:name=".MainActivity"
android:label="#string/name_in_actionbar_and_icon_launcher">
<intent-filter android:label="#string/this_is_useless">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
In Lollipop, android:label in intent-filter is basically useless, while actionbar title and icon launcher is identical. So, if you want a different title in actionbar, you have no choice but to set dynamically
getSupportActionBar().setTitle(R.string.app_name);
You might have to change the name of your main activity "android:label" also, as explained in Naming my application in android
It depends what you want to do. I personally wanted to rename my project so it didn't say MainActivity at the top of the app and underneath the icon on my phone menu.
To do this I went into the Android Manifest.xml file and edited
<activity
android:name=".MainActitivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And edited the android:name=".Mynewname" and then edited the string title_activity_main in the strings.xml file to match the name.
Hope that helps!
if you want to change app name under launcher icon then change this android:label="#string/app_name"
inside your Main Launcher activity tag
<activity android:name="com.test.app"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
And if you want to change app name inside
Settings -> Application manager -> downloaded
where you have all installed applications then change this android:label="#string/app_name"
inside application tag
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
........
<activity android:name="com.test.app" >
</activity>
.......
</application>
To change the name of your Android application in Android Studio or Eclipse, you have to change the value of the property android:label defined inside the <application> node in AndroidManifest.xml
android:label="My Cool Application!"
by default the name of the application is referenced to a string defined in strings.xml file, for example:
android:label="#string/app_name"
so, we have to change the value inside the strings.xml file:
<string name="app_name">My Cool Application!</string>
<application
android:icon="#drawable/app_icon"
android:label="#string/app_name">
<activity
android:name="com.cipl.worldviewfinal.SplashActivity"
android:label="#string/title_activity_splash" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
To change android app's name , go to activity which is launcher activity and change its label like I have done above in my code.
If you're using android studio an item is under your strings.xml
<string name="app_name">BareBoneProject</string>
It's better to change the name here because you might have used this string somewhere.Or maybe a library or something has used it.That's it.Just build and run and you'll get new name.Remember this won't change the package name or anything else.
Nevermind I found it. It can be done in the manifest file under application just set the android label. Was thrown off at first becasue it didn't change my shortcut of the application's name.
Go to Strings.xml file under values.
Change the app_name tag to your app_name to want and it is all set, you will be able to see the name you change now.
follow the steps:(let I assuming you have chosen Android view)
app>res>values>strings
<string name="app_name">Put your App's new name here</string>
Edit the application tag in manifest file.
<application
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" >
Change the label attribute and give the latest name over there.
The change in Manifest file did not change the App name,
<application android:icon="#drawable/ic__logo" android:theme="#style/AppTheme" android:largeHeap="true" android:label="#string/app_name">
but changing the Label attribute in the MainLauncher did the trick for me .
[Activity(Label = "#string/app_name", MainLauncher = true, Theme = "#style/MainActivityNoActionBarTheme", ScreenOrientation = ScreenOrientation.Portrait)]
Old question but also now relative to Xamarin Android development:
As Xamarin allows for attributes to be used for adding items into the manifest, you may need to open your MainActivity.cs file and change the Label tag to your application's name:
Note: This attribute will override written android:label= tags in your manifest file as I found out whilst archiving the app ready for release so be sure to change this attribute too.
Yes Of-course........Android Supports to change the name of the App before making build just like iOS (Build Configuration).
You can change it by Modifying the Android manifest file for the project.
If you are here because when you tried to upload your fresh/brand new application using the play console it displayed this error:
"You must use another package name because "some.package.name" already exists in Google Play."
You just need to go to your build.gradle file (your application) and change
applicationId "some.package.name"
to
applicationId "some.package.different-unique-name"
Other answers here didn't fix this error.
in my case i need invalidate/cache and restart and its work
change the app string resource to your new activity
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.