Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install icon pack on custom launcher?

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);
    }
like image 716
Michele Lacorte Avatar asked Mar 12 '17 19:03

Michele Lacorte


People also ask

Does Microsoft Launcher support icon packs?

Icon Pack Studio has been designed to work with any launcher. However, in order to use your icon packs with your launcher, your launcher needs to support the icon pack studio format, which is one of the most common icon pack formats in the Android market.


2 Answers

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);
            }
        }
like image 82
Michele Lacorte Avatar answered Oct 18 '22 09:10

Michele Lacorte


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.

like image 33
Rajesh Gopu Avatar answered Oct 18 '22 10:10

Rajesh Gopu