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);
}
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With