Label attribute in AndroidManifest.xml - android

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"

Related

When running application A from the launcher it sometimes also runs application B

I have one Gallery application (A) that binds to a service.
I have second transparent application (B) that just runs a service unbound and closes itself.
sometimes - when running application B from the launcher it also runs for a split of a second the application A. I see the layout of application A appears and disappear.
I suspect that something in the manifest is defined wrong : launchMode or taskaffinty.
any ideas?
<application
android:allowBackup="true"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name="com.temp.tempApp.GalleryActivity"
android:theme="#style/AppTheme.NoActionBar"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:label="#string/app_label_gallery"
android:excludeFromRecents="true"
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="com.temp.tempApp.MainActivity"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:launchMode="singleTask"
android:label="#string/app_label"
android:theme="#style/Theme.Transparent"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.temp.tempApp.MainService" android:enabled="true"
android:exported="false">
</service>
Found the answer, one of the following fixed it:
1. add to each activity specific afinity value "android:taskAffinity="com.example.MainActivity""
2. different icons for the 2 activities.
hope it helps somebody in the future

Application starting with different activity, Android Studio

first timer here (both in development and posting in SO). I've used idunnololz to create an animated listview for a simple reference app I'm trying to make. It's turned out really well, but after I've created it, when I run the app to test it, it now runs as AnimatedExpandableListView both in the ActionBar title and in the app drawer. I've searched here and found that you can get the app to launch with a different activity by editing the AndroidManifest.xml, so I verified that I'm pointing to my MainActivity class:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<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>
</application>
I presume this may be an issue with the MainActivity class, but maybe there's something here that I'm missing?
I found my answer here:
Android: App name shows the first page name, not the app name
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter **NEED #string/app_name HERE**>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

How to change activity hierarchy?

I build a project with many activities. Every time, when I was creating new activity, I set a hierarchy parent. But I decided to make an activity with animation, which should be first. I tried to change some information inside manifest file and set the new one activity as the starting activity, but I'm doing something wrong and all the project is crushing. Ofc, I will be keep going and trying to change the manifest file, but maybe I can do that in an easier way using Eclipse tools?
--EDIT--
I solved my problem, it was a quite small mistake. I was just setting wrong layout and forget to change one more thing. I'm not a specialist yet on this topic, but maybe for other readers I will put here some information how to change the hierarchy using manifest file. If I will make any mistakes here, feel free to edit.
Ok, so let's suppose we have our project with a few activities. Inside Manifest file we can find some information about activities, this informations are between markers: . So, it may looks like:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mastermind.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="com.example.mastermind.StartGameActivity"
android:label="#string/title_activity_start_game"
android:parentActivityName="com.example.mastermind.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mastermind.MainActivity" />
</activity>
<activity
android:name="com.example.mastermind.NewActivity"
android:label="#string/title_new_activity" >
</activity>
Now we want to change the MainActivity, which is the first one and set as the first one the NewActivity. We only need to change the name of activity which contains markers:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
for the name of NewActivity and also set it's layout, like this:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mastermind.NewActivity"
android:label="#string/title_new_activity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.mastermind.StartGameActivity"
android:label="#string/title_activity_start_game"
android:parentActivityName="com.example.mastermind.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.mastermind.MainActivity" />
</activity>
<activity
android:name="com.example.mastermind.MainActivity"
android:label="#string/app_name" >
</activity>
That should be Ok.
In the manifest file locate category.LAUNCHER:
<activity
android:name="com.example.StartActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /><!-- This -->
</intent-filter>
</activity>
<activity
android:name="com.example.MainActivity"
android:label="#string/app_name" >
</activity>
The category.LAUNCHER declares your launch Activity.

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"

Having a single application name, and not separate activity names

I have an android application with three activities: Loading, Main, Credits.
But when I try to run and look into the emulator, I have three icons: Loading, Main, Credits.
How can I just have a single Application name? And where do I set it?
Set in android manifest file in application level.
android:label="#string/app_name"
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Loading"
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=".Main" />
<activity android:name=".Credits" />
In your AndroidManifest.xml, you just need to set <intent-filter> for only one Activity other Activities don't need this tag.

Categories

Resources