0

I write two simple activities and give them both the category as android.intent.category.LAUNCHER.

How will the android System decide which activity to launch ? In my test, it was launching the SecondActivity.

 <activity android:name="in.co.madhur.activitiestest.SecondActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <activity
            android:name="in.co.madhur.activitiestest.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124

1 Answers1

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

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

In 2 activities will Put 2 Icons in your launcher screen for each activity.

You need to specify which activity is the default one by adding the following line to your intent-filter:

<category android:name="android.intent.category.DEFAULT"/>
Piyush
  • 2,040
  • 16
  • 14
  • Ok, I understood. But how about removing this category "" from the non-default one. Can you elaborate on the difference ? – Madhur Ahuja Oct 02 '13 at 08:46
  • 1
    What do you actually want, if you want only one icon and on clicking it you want to launch activity MainActivity then put intent-filter in mainActivity and remove it from secondactivity. – Piyush Oct 02 '13 at 08:51
  • I want to know the purpose of android.intent.category.DEFAULT – Madhur Ahuja Oct 02 '13 at 08:53
  • You will find your answere at http://stackoverflow.com/questions/5727828/what-is-the-purpose-of-android-intent-category-default – Piyush Oct 02 '13 at 09:05