I am developing an application that has the ability to change the icon that is displayed in the launcher. I share the code that does this. I understand that this is not a forum for developers, so you can imagine that there are several icons in the application, but only one is always displayed in the launcher.
public static void setIcon(LauncherIcon icon) {
Context ctx = ApplicationLoader.applicationContext;
PackageManager pm = ctx.getPackageManager();
for (LauncherIcon i : LauncherIcon.values()) {
pm.setComponentEnabledSetting(i.getComponentName(ctx), i == icon ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
}
I wanted to write a command that would know which icon is currently active. This can just be determined by taking from somewhere a list of only active activity-alias
es. Since the control in the code happens through the PackageManager
, I assume that in the terminal this is possible with the pm
utility. But I didn't find anything to help me. As I understand it, somehow through pm
I can get a list of activity-alias
es, and then for each get the properties COMPONENT_ENABLED_STATE_ENABLED
or COMPONENT_ENABLED_STATE_DISABLED
, which I specify in the code. If I find the property COMPONENT_ENABLED_STATE_ENABLED
then I should get the name of this activity-alias
.