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>
4

1 回答 1

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

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

在 2 个活动中,将为每个活动在您的启动器屏幕中放置 2 个图标。

您需要通过将以下行添加到您的意图过滤器来指定哪个活动是默认活动:

<category android:name="android.intent.category.DEFAULT"/>
于 2013-10-02T08:36:16.057 回答