I am using the below code to change the app icon programmatically. but it's killing the app the first time we change the icon. how to avoid killing the app while changing the app icon.
PackageManager packageManager = getPackageManager();
packageManager.setComponentEnabledSetting(new ComponentName("package name", "class name"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
//enables the second icon
packageManager.setComponentEnabledSetting(new ComponentName("package name", "class alias"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
Unfortunately, the application has to
kill
. But as an alternative, I can make the following suggestion. You can change it after the application closes.You can achieve this through a service.
Manifest.xml
Service.kt
Add Service Manifest
Service Added