Android Launcher3修改应用图标,隐藏应用图标
来源:互联网 发布:中高端女装品牌 知乎 编辑:程序博客网 时间:2024/05/29 09:04
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<Object, CharSequence> 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; }
阅读全文
0 0
- Android Launcher3修改应用图标,隐藏应用图标
- Android Launcher3 隐藏指定应用图标
- 修改android N的Launcher3桌面应用图标
- 隐藏android应用图标
- android应用隐藏图标
- Android隐藏应用图标
- Android Launcher3修改行数,列数,布局等;隐藏HostSeat,使用户无法拖拽应用图标到Hotseat
- 在android N 的Launcher3中隐藏某些app应用图标
- Android Launcher3安装应用后,控制应用图标显示位置
- 修改Launcher3的workspace的应用图标的行列数:
- 修改Launcher3中的workspace中的应用图标的大小
- 如何隐藏android应用图标?
- Android隐藏app应用图标
- Android 显示/隐藏 应用图标
- Android 修改应用图标icon
- Launcher3 应用图标的加载流程
- 隐藏应用图标。
- 一个隐藏android应用图标的方法
- 数据集与标注等工具
- virtualbox安装centos7
- 使用cocoapods导入第三方后 报错_OBJC_CLASS_$_XXX
- 浅谈UML---协作图
- RTMP直播到FMS中的AAC音频直播
- Android Launcher3修改应用图标,隐藏应用图标
- java基础购物选择数量计算,结算找零
- FZU 2282 Wand(错排+费马小定理)
- 自动装箱与拆箱的等于比较
- FARROW 滤波器
- struts2基本流程和action的对应
- 在把jQuery的ajax例子放在AppServ上运行时出错,failed to open stream: No such file or directory in Unknown on line 0
- Leetcode-Combination Sum ll(深搜)
- android下使用FTP上传文件、下载文件、新建目录、删除文件工具类