1.activity设置intent-filter
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
2.activity-alias
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="true"
android:icon="@drawable/桌面图标"
android:label="图标名称"
android:launchMode="singleInstance"
android:theme="@style/MainTheme">
</activity>
<activity-alias
android:name="唯一标记"
android:enabled="true"//为true才显示
android:icon="@drawable/桌面图标"
android:label="图标名称"
android:launchMode="singleInstance"
android:targetActivity="目标activity(.MainActivity)">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
============================================
注意:xml文件里面有多个
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
此时,要把默认打开的设置为
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
网友评论