Launcher运行时,会执行LauncherModel的loadAllApps方法,加载所有应用的详细信息。这时候,如果你想过

滤掉你不想显示的应用,你可以修改源码,把应用过滤掉。

我这里的示列是Launcher第一次加载时,会把Android的键盘应用添加到主页面。所以我需要把该应用隐藏,不

显示在Launcher桌面。这里贴LoadAllApps的部分代码。

// Create the ApplicationInfosfor (int i = 0; i < apps.size(); i++) {    LauncherActivityInfoCompat app = apps.get(i);    // This builds the icon bitmaps.    AppInfo appInfo = new AppInfo(mContext, app, user, mIconCache, mLabelCache);//  Log.e(TAG, "packagename: "+appInfo.componentName.getPackageName());    //隐藏AndroidAOSP加载到桌面    if (!appInfo.componentName.getPackageName().equals("com.android.inputmethod.latin")){        mBgAllAppsList.add(appInfo);//  Log.e(TAG, "packagename222: "+appInfo.componentName.getPackageName());    }else{        //过滤掉该APP,不显示在Launcher界面中    }}

通过追踪代码,你会发现,控制APP应用图标的代码在IconCache的cacheLocked方法中。当然,你也可以在其他地方修改。这个没有限制。判断应用的包名和你应用的需要修改的一致,这时候就可以修改应用的包名了

 

/** * Retrieves the entry from the cache. If the entry is not present, it creates a new entry. * This method is not thread safe, it must be called from a synchronized method. */private CacheEntry cacheLocked(ComponentName componentName, LauncherActivityInfoCompat info,        HashMap labelCache, UserHandleCompat user, boolean usePackageIcon) {    CacheKey cacheKey = new CacheKey(componentName, user);    CacheEntry entry = mCache.get(cacheKey);    if (entry == null) {        entry = new CacheEntry();        mCache.put(cacheKey, entry);        if (info != null) {            ComponentName labelKey = info.getComponentName();            if (labelCache != null && labelCache.containsKey(labelKey)) {                entry.title = labelCache.get(labelKey).toString();            } else {                entry.title = info.getLabel().toString();                if (labelCache != null) {                    labelCache.put(labelKey, entry.title);                }            }            entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);            entry.icon = Utilities.createIconBitmap(                    info.getBadgedIcon(mIconDpi), mContext);            Log.d(TAG, "PackageName: "+componentName.getPackageName());                                    /**             * 这里修改图标             */            //设置            if (componentName.getPackageName().equals("com.android.settings")) {                Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(),                        R.mipmap.system_setting);                entry.icon = bitmap;            }

 

更多相关文章

  1. Android实机调试出现“您的手机未安装此应用”
  2. Android(安卓)Notification
  3. android 简单推送socket长链接
  4. 安卓巴士真诚送上营养丰富的精美Android大餐
  5. Android(安卓)multidex 使用 与 实现原理
  6. 第一个Android实例——计算器 编辑
  7. 在 Android(安卓)中调用二进制可执行程序(native executable )
  8. [Android--Tool]Android如何将他人的代码放入新建的工程中
  9. Android自带音乐播放器代码分析(2)

随机推荐

  1. PHP / Ajax:如何在成功登录后启动会话(剩
  2. php单引号和双引号的区别
  3. GET 与 POST 的理解
  4. php调整图像大小
  5. php exec文件从终端运行,而不是从浏览器运
  6. PHPExcel导入导出及大量数据导入缓存方式
  7. 为什么file_put_contents在从浏览器运行
  8. 从。net调用Magento API,并得到“位于XYZ
  9. 单击动态创建的复选框时,通过AJAX / PHP更
  10. PHP168整站系统山寨版闪亮登场