How do I get multiple icons to launch different activities in one application?

Viewed 23605

I have an application with two activities and I'd like to be able to have two icons appear in the launcher, each launching the respective activity within the app.

Specifically, I want one icon to launch my main app, and another icon to launch my settings activity. Is this possible?

Here is what I've tried so far:

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


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

This creates two launcher icons, but they both run my main app instead of the second icon running my settings app. I've tried just having the launcher category but then I don't get an icon so it looks like I need the main action as well.

Is this the right approach or should I be declaring two applications in the manifest instead?

2 Answers
Related