0

I recently changed the launch activity of my app - by moving the intent-filter (action.MAIN and category.LAUNCHER) in the manifest from the old activity to the new - and since then the new activity name rather than the application name shows in the All Applications list on my test phone (running Android version 2.3.6). In the 'Manage Applications' list it still shows the app name.

It's not a huge deal - because I can always just create a new app with the new launcher activity as default - but it would be nice have the flexibility to change the launcher activity on the fly in the same project. Basically is there something else, other than just cutting and pasting the intent-filter in the manifest, that needs to be done to change the default launcher activity? That is, assuming that's the cause of the problem.

Thanks in advance for any help.

mark_w
  • 253
  • 1
  • 2
  • 9

3 Answers3

3

From this answer and the Android Documentation:

Use the android:label="@string/activity_sample_code" on the application element in the Manifest. This will then determine the string displayed to the user as the application name.

Update: The application level label will provide a default for all child-elements. If you override the label on an activity, that label will take precedence. You can again override that activity label with a label on the intent filter! The section in the Android documentation about icons and labels covers that nicely:

In every case, the icon and label set in a containing element become the default icon and label settings for all of the container's subelements.

For simple applications, a label on the application suffices.

TL;DR: For the launcher, the label wins that is found first in this order: LAUNCHER-IntentFilter, Activity with Launcher IntentFilter, Application

Community
  • 1
  • 1
Patrick
  • 4,720
  • 4
  • 41
  • 71
  • Hi there. The above attribute is already in the application tag of the manifest. – mark_w Jul 08 '13 at 13:48
  • Hi mark. Do you have a label set for your `intent-filter`? This would override the one set in the application element. The documentation explains this quite nicely. I'll update the answer with a link. – Patrick Jul 08 '13 at 13:54
  • Beautiful, thank you :-) So in other words if you want to make an app where the launcher activity is easily adjustable on-the-fly you just make sure your intent-filter tag contains the android:label="@string/app_name", then you can cut and paste it at will and keep the activity labels undisturbed in case you change your mind. Brilliant! – mark_w Jul 08 '13 at 14:30
  • Correct. And this also allows giving different intent-filters different labels (e.g. like we see 'Add to Dropbox' when using a Share menu, and not just 'Dropbox'). Glad to be able to help :) – Patrick Jul 08 '13 at 15:05
1

Just remove the following tag from your new selected Launcher Activity:

android:label="xyz"

Removing this tag will fix the problem, and yes you can change Launcher Activity anytime by just copy pasting those tags. You can also add this tag to your application tag.

M-Wajeeh
  • 17,204
  • 10
  • 66
  • 103
  • Remove the name? I can't remove the name - it's a required attribute of an activity in the manifest. Have I misunderstood you? And regarding the second point, the app name label is already in the application tag. – mark_w Jul 08 '13 at 13:43
  • I understand what you mean now - I think you meant android:label rather than android:name. Yes, removing the label for an activity does solve the problem, but a better solution is the accepted answer which actually lets you leave those individual activity labels untouched :-) – mark_w Jul 08 '13 at 14:43
0

you could see this link

the answer is so great:

  android:name=".ui.HomeActivity"
  android:label="@string/title_home_activity"
  android:icon="@drawable/icon">
  <intent-filter android:label="@string/app_`enter code here`name">
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>
Community
  • 1
  • 1
evan
  • 318
  • 3
  • 14