如何在自定义启动器上安装图标包?

我试图在我的自定义启动器上安装图标包,我读过这个笔记如何安装图标包,但我无法理解如何使用该类,这是我做的:

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

Solutions Collecting From Web of "如何在自定义启动器上安装图标包?"

解决这个问题:

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

只有在安装了以下任何一个软件包的情况下,

1)是否安装?

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

getAvailableIconPacks应该返回HashMap大小> 0

2)在下面返回有效的drawable还是null?

  d = packIcon.getDrawableIconForPackage(packName, iconDrawable); 

用法在你的情况是错误的。

你正在迭代抛出图标提供程序包names.SO在下面的情况下你的要求

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

所以没有上面的主题从谷歌播放安装只返回默认的绘制。