21

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);
    }
Community
  • 1
  • 1
Michele Lacorte
  • 4,546
  • 5
  • 28
  • 52

2 Answers2

7

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);
            }
        }
Michele Lacorte
  • 4,546
  • 5
  • 28
  • 52
2

This works only if any of below packages are installed ,

1) Is it installed ?

org.adw.launcher.THEMES
com.gau.go.launcherex.theme

getAvailableIconPacks should return HashMap size >0

2) is below returning valid drawable or null?

 d = packIcon.getDrawableIconForPackage(packName, iconDrawable);

Usage is wrong in your case.

Your are iterating throw icon providers package names.SO in below case your are asking for

d = packIcon.getDrawableIconForPackage(packName, iconDrawable);
//means 
//d = packIcon.getDrawableIconForPackage("org.adw.launcher.THEMES",conDrawable)

so without above themes installation from google play it returns the default drawables only.

Rajesh Gopu
  • 793
  • 6
  • 24