java – How to install icon pack on custom launcher?-ThrowExceptions

Exception or error:

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);
    }
How to solve:

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);
            }
        }

###

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.

Leave a Reply

Your email address will not be published. Required fields are marked *