1

I have my application and I would like to have two different launchers that each launch different activities. They should all be bundled into one apk and not two separate applications. I know this is possible, example in the XKCD Browser on the Google play store. I have already tried implementing this segment in the second activity I need to be in the launcher:

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

This results in the first activity declared as MAIN to be launched when clicking the second launcher. I have also tried:

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

As well as:

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

Which achieves the same result. I need this to function down to API 17. Ideas?

gvlasov
  • 18,638
  • 21
  • 74
  • 110
IambicSam
  • 11
  • 1
  • 2
  • 1
    Do you have the default category defined anywhere in the manifest? ` ` – Micky Feb 20 '15 at 14:53
  • 1
    Also, you might need to set the `android:taskAffinity` for both Activities to avoid clicking on the second launcher to start the first app when it's already in memory. – Micky Feb 20 '15 at 14:57
  • 1
    See here: http://stackoverflow.com/questions/15526805/two-main-activities-in-androidmanifest-xml – Micky Feb 20 '15 at 14:59

2 Answers2

1

You should have a main activity with:

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

And any other activity with only the category part:

<intent-filter>
    <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
natario
  • 24,954
  • 17
  • 88
  • 158
  • This results in a system Toast saying "App isn't installed" – IambicSam Feb 20 '15 at 13:57
  • @Iambic that's quite strange. Be sure to use only one `MAIN` intent filter and re-install your app. If the issue persists, I imagine there might be problems depending on your activity code. E.g., is your second activity linked to a proper Activity class? Please post your manifest file. – natario Feb 20 '15 at 14:02
  • Re-installed the application and the second activity does not appear as a launcher. – IambicSam Feb 20 '15 at 14:11
0

Maybe you need to put the same date frome place where your call intent for start app

<activity
android:name="com.spectrum.media.activity.InitializationScreen" 
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MUSIC_PLAYER" />

<category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.APP_MUSIC" />
<action android:name="android.intent.action.MEDIA_BUTTON" />
                <action android:name="android.media.AUDIO_BECOMING_NOISY" />
</intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="application/ogg" />
                <data android:mimeType="application/x-ogg" />
                <data android:mimeType="application/itunes" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="application/ogg" />
                <data android:mimeType="application/x-ogg" />
                <data android:mimeType="application/itunes" />
            </intent-filter>
            <intent-filter android:priority="-1">
                <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" />
                <data android:mimeType="audio/*" />
                <data android:mimeType="application/ogg" />
                <data android:mimeType="application/x-ogg" />
                <data android:mimeType="application/itunes" />
           </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
                <!-->category android:name="android.intent.category.BROWSABLE" />;-->
</intent-filter>
</activity>

And parse this scheme in first activity and run others if necessary.

QArea
  • 4,955
  • 1
  • 12
  • 22