4

I know this question has been asked before but in all of them the answer is to set it from onCreate method of activity. I DO NOT want to do this in my onCreate method, so I did this to my manifest file, but to no avail:-

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher_screen"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light"
         >
        <activity
            android:name="com.iws.unify.HomeScreen"
            android:label="@string/nullstring"
            android:icon="@drawable/ic_launcher"
             >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

For some reason whatever icon/label I set in activity overrides that in application tag which is so annoying. Please help.

Chintan Trivedi
  • 748
  • 1
  • 8
  • 21
  • please read this ,it is the answer [question][1] [1]: http://stackoverflow.com/questions/3488664/android-launcher-label-vs-activity-title – evan Oct 28 '13 at 10:37

4 Answers4

15

If all you need is to have an activity action bar icon different from application icon, you can override it using "android:logo" attribute for that:

    <activity
        android:name="com.iws.unify.HomeScreen"
        android:label="@string/nullstring"
        android:logo="@drawable/ic_launcher">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Eugene
  • 165
  • 1
  • 5
4

I had the same problem, i solved using a Very weird but simple solution.

1- create a new activity and call it LauncherActivity.(set the icon and label of this activity what you want to be displayed as the application icon/label)

2- set this activity as the main & launcher activity of your app.(remove the <intent-filter> tag from your HomeScreen activity)

3- set the theme of this activity to android:theme="@android:style/Theme.Translucent"

4- now in your LauncherActivity onCreate() don't do anything just start the HomeScreen activity using an intent and finish this activity.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = new Intent(this, HomeScreen.class);
    startActivity(intent);
    finish();
}

finish() is required so when you press the back button in your HomeScreen the app closes.

now your app icon and label will be different from your HomeScreen Icon and label

your manifest should look like:

<application
    android:allowBackup="true"
    android:theme="@android:style/Theme.Holo.Light"
     >
    <activity
        android:name="com.iws.unify.HomeScreen"
        android:label="@string/nullstring"
        android:icon="@drawable/ic_launcher"
         >
    </activity>

    <activity
        android:name="com.iws.unify.LauncherActivity"
        android:icon="@drawable/ic_launcher_screen"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Tarek K. Ajaj
  • 2,461
  • 1
  • 19
  • 24
1

Answer:

Remove the icon in the android activity.

Extra info:

The main activity with the activity launcher will be considered by android runtime.

For example: IF you declare the following code in two activity "a" and "b".:

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

Then your application will have two launcher icons "a" and "b".

amalBit
  • 12,041
  • 6
  • 77
  • 94
  • I'm sorry I didn't get it. If I have two launcher activities how would it solve my problem? – Chintan Trivedi Jun 19 '13 at 13:41
  • Adding the extra activity is not the solution... Its just that i confused u i think.. @NewOverHere, Just remove the icon attribute inside your activity. – amalBit Jun 19 '13 at 13:43
  • But I want to have different icons for my application and main activity. By your suggestion I will end up with same app icon and activity icon. Thanks for helping though. Any other suggestion? – Chintan Trivedi Jun 19 '13 at 13:46
  • But y do u want a different icon for both.. am curious – amalBit Jun 19 '13 at 13:47
  • Because my icon is text in blue+red color with transparent background which looks fantastic in action bar but is unreadable on home screen due to the wallpaper. So I set a white background for app icon and original icon with no background for action bar. – Chintan Trivedi Jun 19 '13 at 13:52
0

You can also use "activity-alias" :

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo.Light">

    <activity
        android:name="com.iws.unify.HomeScreen"
        android:label="@string/nullstring"
        android:exported="true" />             

    <activity-alias
        android:name=".LaucherActivityAlias"
        android:targetActivity="com.iws.unity.HomeScreen"
        android:icon="@drawable/ic_launcher_screen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>

</application>

Your "playstore" icon will be the one specified in the application node, so you can also do this if you need :

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher_screen"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo.Light">

    <activity
        android:name="com.iws.unify.HomeScreen"
        android:label="@string/nullstring"
        android:icon="@drawable/ic_launcher"
        android:exported="true" />             

    <activity-alias
        android:name=".LaucherActivityAlias"
        android:targetActivity="com.iws.unity.HomeScreen"
        android:icon="@drawable/ic_launcher_screen">
        <intent-filter>
        <action android:name="android.intent.action.MAIN" />
             <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>

</application>