56

My Android App has 2 activities. A login screen and a search screen. When I deploy the app on emulator or on my device, I see 2 icons for same app. When I click on icon 1 it opens screen 1 (login screen) and When I click on icon 2 it opens screen 2 (search screen). By logic when I login it should show the search screen. Not sure when I'm making the mistake.

3 Answers 3

92

Your manifest file should only have this line in the activity you want to have an icon:

<category android:name="android.intent.category.MAIN" />

Based on your description, it sounds like both activities have this line.

4
  • 6
    MAIN is not a category; it is an action. More generally, do not include an <intent-filter> for an activity in the manifest unless you need one. For simple apps, only the activity that needs an icon in the launcher should have an <intent-filter>. Aug 20, 2010 at 0:30
  • Hi Aaron, Thank you so much for the quick revert. Yes this was the issue and the app works as intended. Thanks again. Regards, Aravind. C
    – Aravindan. C
    Aug 20, 2010 at 0:40
  • 3
    You should check also the manifest for referenced library projects
    – Adrian C.
    Mar 7, 2013 at 18:59
  • Thanks for the little detail.
    – Samir
    Jul 26, 2017 at 7:46
27

In your mainfest file when you have following tag in two different activities tags at the time, Android app seems to be installed twice.

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>    
2
  • 6
    I've got same problem because I included a library as project dependency, whose AndroidManifest.xml contained an intent filter definition -> I removed it and everything started working correctly!
    – notsoux
    Mar 27, 2014 at 19:01
  • 1
    Actually, I have this in two different activities, because I want each to behave as an independent app. It works as desired. I tried with "CREATE_SHORTCUT", but the shortcut does not stays in the home screen. Sep 3, 2014 at 0:41
5

The comment made by @Adrian C on his answer solved our problem.

The manifest file of our main application had only one intent-filter tag specifying only one activity as the launcher activity for the application.

So I had to look deeper...

We included library projects (luckily written by us) and the manifest file of one of the library projects had an intent-filter tag on its activity specifying that activity as the launcher activity.

When we then included that library project in our main application (which has its own intent-filter specifying a launcher activity), the complete source code saw two intent-filter tags specifying two activities as launcher activities and therefore two application icons were created.

When we removed the intent-filter specifying a launcher activity in the library project, the second app launcher icon disappeared.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.