In my application, I want to change the application icon based on the notification received. that is, if 2 notifications are received, the application icon having “2” in it will be displayed on the device’s main screen.
For this, I used an activity alias. I added the following intent filters for the activity alias:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
And to make the alias active, I used the following code:
This means that the activity alias:
ComponentName componentName = new ComponentName("PACKAGE_NAME_HERE",
lastEnabled);
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
Utility.setLastEnabled(lastEnabled,context);
This will disable the previously activated activity alias.
componentName = new ComponentName(
"PACKAGE_NAME_HERE", prevLastEnabled);
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP);
, - . dont kill , . -, , , - . .