尝试使用活动别名为我的应用程序使用多个图标。这是我的清单代码:
<activity
android:name=".splashscreen.SplashScreen"
android:launchMode="singleTask"
android:label="@string/app_name">
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
</activity>
<activity-alias
android:name="com.sharesmile.share.splashscreen.SplashScreenmain"
android:targetActivity=".splashscreen.SplashScreen"
android:label="test"
android:icon="@mipmap/ic_launcher"
android:enabled="false"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
<activity-alias
android:name="com.sharesmile.share.splashscreen.SplashScreenpinkathon"
android:targetActivity=".splashscreen.SplashScreen"
android:label="testpinkathon"
android:icon="@mipmap/ic_launcher_pink"
android:enabled="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
这是我在oncreate的启动画面活动中的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPackageManager().setComponentEnabledSetting(
new ComponentName("com.sharesmile.share", "com.sharesmile.share.splashscreen.SplashScreenpinkathon"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
setContentView(R.layout.activity_splash_screen);
...
}
现在在进行测试时,我将 com.sharesmile.share.splashscreen.SplashScreenpinkathon 更改为 com.sharesmile.share.splashscreen.SplashScreenmain ,但这并不反映出来。似乎是什么问题?
答案 0 :(得分:0)
答案很简单,我必须为一个别名设置启用,而为另一个别名设置禁用。
赞:
getPackageManager().setComponentEnabledSetting(
new ComponentName("com.****.8888", "abc.SplashScreenA"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
getPackageManager().setComponentEnabledSetting(
new ComponentName("com.sharesmile.share", "com.sharesmile.share.splashscreen.SplashScreenmain"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);