How to install icon pack on custom launcher?

Michele Lacorte :

I'm trying to install icon pack on my custom launcher, I've read this note How to install icon pack but I'm not able to understand how to use that class, here's what I done:

IconPackManager ic = new IconPackManager();
HashMap<String, IconPackManager.IconPack> map = new HashMap<String, IconPackManager.IconPack>(ic.getAvailableIconPacks(false));
Iterator it = map.entrySet().iterator();
Drawable d = null;
String packName = null;
IconPackManager.IconPack packIcon = null;
    while (it.hasNext()) {
       Map.Entry pair = (Map.Entry)it.next();
       packName = (String)pair.getKey();
       packIcon = (IconPackManager.IconPack)pair.getValue();
       d = packIcon.getDrawableIconForPackage(packName, iconDrawable);
       setIcon(d);
    }
Michele Lacorte :

Solved with this:

String packName = null;
IconPackManager.IconPack packIcon = null;

IconPackManager ic = new IconPackManager();
HashMap<String, IconPackManager.IconPack> map = ic.getAvailableIconPacks(true);
Iterator it = map.entrySet().iterator();


        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry)it.next();
            packName = (String)pair.getKey(); //Get icon pack name (app package)

            packIcon = (IconPackManager.IconPack)pair.getValue(); //Get icons

            if(packIcon.getDrawableIconForPackage("YourTargetPackageName", yourStandardIcon) != null) {

            //Your own method for set icon   
            setIcon(packIcon.getDrawableIconForPackage("YourTargetPackageName", yourStandardIcon));

            }else{
                //Your own method for set icon   
                setIcon(yourStandardIcon);
            }
        }

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=447253&siteId=1