android隐藏某apk主菜单 (一)
来源:互联网 发布:餐厅进销存软件 编辑:程序博客网 时间:2024/06/06 20:36
最近在弄一个需求,要求硬件支持ATV的话,就将ATV主菜单显示出来,否则不显示ATV主菜单。
查了些资料,最开始在launcher里修改,可以实现此功能。在launcher里修改方法:
当launcher在加载所有apk时,判断硬件是否支持atv,若支持,请查看代码:
这是在2.3.5上修改的:
packages/apps/hylauncher/src/com/android/hylauncher
public ApplicationsAdapter(Context context, ArrayList<ApplicationInfo> apps, AppCatalogueFilter filter) {super(context, 0, apps);mCatalogueFilter = filter;mInflater = LayoutInflater.from(context);// HY: Load textcolor and bubble color from themeString themePackage = AlmostNexusSettingsHelper.getThemePackageName(getContext(), Launcher.THEME_DEFAULT); if (!themePackage.equals(Launcher.THEME_DEFAULT)) {Resources themeResources = null;try {themeResources = getContext().getPackageManager().getResourcesForApplication(themePackage);} catch (NameNotFoundException e) {// e.printStackTrace();}if (themeResources != null) {int textColorId = themeResources.getIdentifier("drawer_text_color", "color", themePackage);if (textColorId != 0) {mTextColor = themeResources.getColor(textColorId);useThemeTextColor = true;}mBackground = IconHighlights.getDrawable(getContext(),IconHighlights.TYPE_DRAWER); try{ themeFont=Typeface.createFromAsset(themeResources.getAssets(), "themefont.ttf"); }catch (RuntimeException e) {// TODO: handle exception}}}}
在上面这个函数中String themePackage = AlmostNexusSettingsHelper.getThemePackageName(
getContext(), Launcher.THEME_DEFAULT); 后加上判断条件:
try { if (IfExistFile("/sys/class/atv/nmi/dev")) { is_atv_exist = true; Log.v(TAG, "is_atv_exist = " + is_atv_exist); } else { is_atv_exist = false; Log.v(TAG, "is_atv_exist = " + is_atv_exist); } }catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); is_atv_exist = false; Log.v(TAG, "the atv is not exist"); }这里用到了一个判断文件是否存在的函数:
private boolean IfExistFile(String fileName) throws FileNotFoundException { // TODO Auto-generated method stub File file = new File(fileName); if (file.exists()) { return true; } else { return false; } }下面要找到加载所有apk的地方:
@Overridepublic void add(ApplicationInfo info) {//check allItems before added. It is a fix for all of the multi-icon issue, but will //lose performance. Anyway, we do not expected to have many applications.synchronized (allItems) {/*if (!allItems.contains(info)) {changed = true;allItems.add(info);Collections.sort(allItems,new ApplicationInfoComparator());}*/int count=allItems.size();boolean found=false; boolean update=false;for(int i=0;i<count;i++){ApplicationInfo athis=allItems.get(i);if(info.intent.getComponent()!=null){if(athis.intent.getComponent().flattenToString().equals(info.intent.getComponent().flattenToString())){ if (0 != athis.title.toString().compareTo(info.title.toString())) { athis.title = info.title; update = true; }found=true;break;}}}if(!found){allItems.add(info);Collections.sort(allItems,new ApplicationInfoComparator());if(SprdFeatureUtils.SPRD_APP_HYLAUNCHER_ICON_SORT){HyLauncherFunctionIconSort();}updateDataSet();} else if (update) {Collections.sort(allItems,new ApplicationInfoComparator());if(SprdFeatureUtils.SPRD_APP_HYLAUNCHER_ICON_SORT){HyLauncherFunctionIconSort();}updateDataSet();mUpdateViewCache = true;}} }添加上符合判断条件的操作:不让加载此apk菜单:
if(info.intent.getComponent().getClassName().equals("com.example.onekeyclearrecentslist.ClearMainActivity") && !is_atv_exist){
if(info.intent.getComponent().getClassName().equals("com.nmi.test.test") && !is_atv_exist){
Log.v(TAG, "dont add the atv application");
return;
}
加完之后就是以下的样子:
@Overridepublic void add(ApplicationInfo info) {//check allItems before added. It is a fix for all of the multi-icon issue, but will //lose performance. Anyway, we do not expected to have many applications.synchronized (allItems) {/*if (!allItems.contains(info)) {changed = true;allItems.add(info);Collections.sort(allItems,new ApplicationInfoComparator());}*/int count=allItems.size();boolean found=false; boolean update=false;for(int i=0;i<count;i++){ApplicationInfo athis=allItems.get(i);if(info.intent.getComponent()!=null){if(info.intent.getComponent().getClassName().equals("com.example.onekeyclearrecentslist.ClearMainActivity") && !is_atv_exist){ if(info.intent.getComponent().getClassName().equals("com.nmi.test.test") && !is_atv_exist){ Log.v(TAG, "dont add the atv application"); return; }else if(athis.intent.getComponent().flattenToString().equals(info.intent.getComponent().flattenToString())){ if (0 != athis.title.toString().compareTo(info.title.toString())) { athis.title = info.title; update = true; }found=true;break;}}}if(!found){allItems.add(info);Collections.sort(allItems,new ApplicationInfoComparator());if(SprdFeatureUtils.SPRD_APP_HYLAUNCHER_ICON_SORT){HyLauncherFunctionIconSort();}updateDataSet();} else if (update) {Collections.sort(allItems,new ApplicationInfoComparator());if(SprdFeatureUtils.SPRD_APP_HYLAUNCHER_ICON_SORT){HyLauncherFunctionIconSort();}updateDataSet();mUpdateViewCache = true;}} }编译此模块,push到手机里,验证是否还会有atv菜单。
- android隐藏某apk主菜单 (一)
- android隐藏某apk主菜单 (二)
- Android 自定义主菜单
- 如何隐藏主菜单下一个apk的图标,不让其显示?
- android 返回主菜单 Home
- Android 程序主菜单 布局
- Android之动画主菜单
- android 如何让应用程序在主菜单[launcher]程序列表中动态显示或隐藏
- android 仿iphone主题之主菜单
- android 仿iphone主题之主菜单
- android,点击返回按钮回到主菜单
- Android Launcher3主菜单背景改为黑色
- 在Launcher隐藏主菜单中某个应用
- 源码修改之修改Launcher隐藏主菜单图标
- 飞机大战项目(1)主菜单
- android 如何定制Launcher主菜单中应用程序图标在主菜单中的显示顺序
- android 如何定制Launcher主菜单中应用程序图标在主菜单中的显示顺序
- Android游戏开发之绘制游戏主菜单与进度条加载进度(十三)
- 搭建hadoop-0.20.2开发测试环境(一)
- Linux软件的卸载
- Oracle系列:安装Oracle RAC数据库(一)
- 【转】Windows批处理学习(二)——批处理(1)
- Oracle系列:安装Oracle RAC数据库(二)
- android隐藏某apk主菜单 (一)
- jquery自定义动画的函数切换函数
- hdu(1163)Eddy's digital Roots
- Oracle系列:安装Oracle RAC数据库(三)
- HDU 2602 Bone Collector(最简单的0/1背包问题)
- javascript获得当前对象的位置
- poj 3140 Contestants Division
- mybatis返回int类型报错
- mysql导入,导出数据库