Trying to use activity-alias for using multiple icons for my application. This is my manifest code :
<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>
And this is my code in the splashscreen activity in 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);
...
}
now when for testing I change com.sharesmile.share.splashscreen.SplashScreenpinkathon to com.sharesmile.share.splashscreen.SplashScreenmain it does not reflect. What seems the issue?
The answer was very simple, I had to set enabled for one alias and disabled for the other.
Like this :
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);