问题描述:

开机完成并解锁后,如果系统存在多个Launcher,系统会弹出一个选择框让用户选择进入某个Launcher。如果用户不想选择,而是想直接进入某一个默认的Launcher,要怎么修改?

frameworks\base\services\core\java\com\android\server\am\ActivityManagerService.javaboolean startHomeActivityLocked(int userId, String reason) {+    setDefaultLauncher();if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL&& mTopAction == null) {// We are running in factory test mode, but unable to find// the factory test app, so just sit around displaying the// error message and don't try to start anything.return false;}private void setDefaultLauncher() {boolean mFirstLaunch = true;String packageName = "默认launcher包名";String className = "默认launcher入口";if ((packageName != null && packageName.trim().length() > 1) && (className != null && className.trim().length() > 0)) {if(mFirstLaunch){IPackageManager pm = ActivityThread.getPackageManager();ArrayList<IntentFilter> intentList = new ArrayList<IntentFilter>();ArrayList<ComponentName> cnList = new ArrayList<ComponentName>();mContext.getPackageManager().getPreferredActivities(intentList, cnList, null);IntentFilter dhIF;for(int i = 0; i < cnList.size(); i++){dhIF = intentList.get(i);if(dhIF.hasAction(Intent.ACTION_MAIN) &&dhIF.hasCategory(Intent.CATEGORY_HOME)){mContext.getPackageManager().clearPackagePreferredActivities(cnList.get(i).getPackageName());}}Intent intent = new Intent(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_HOME);List<ResolveInfo> list = new ArrayList<ResolveInfo>();try {list = pm.queryIntentActivities(intent,intent.resolveTypeIfNeeded(mContext.getContentResolver()),PackageManager.MATCH_DEFAULT_ONLY,UserHandle.getCallingUserId()).getList(); //add .getList()}catch (RemoteException e) {throw new RuntimeException("Package manager has died", e);}// get all components and the best matchIntentFilter filter = new IntentFilter();filter.addAction(Intent.ACTION_MAIN);filter.addCategory(Intent.CATEGORY_HOME);filter.addCategory(Intent.CATEGORY_DEFAULT);final int N = list.size();Slog.d(TAG, "N:::::hyhyhyhy:::: = " + N);ComponentName[] set = new ComponentName[N];int bestMatch = 0;for (int i = 0; i < N; i++){ResolveInfo r = list.get(i);set[i] = new ComponentName(r.activityInfo.packageName,r.activityInfo.name);Slog.d(TAG, "r.activityInfo.packageName:::::hyhyhyhy:::: = " + r.activityInfo.packageName);Slog.d(TAG, "r.activityInfo.name:::::hyhyhyhy:::: = " + r.activityInfo.name);if (r.match > bestMatch) bestMatch = r.match;}//<C9><E8><D6><C3>?<C8><CF>launcherComponentName launcher = new ComponentName(packageName, className);try{Log.d("zy","pm.addPreferredActivity");pm.addPreferredActivity(filter, bestMatch, set, launcher,UserHandle.getCallingUserId());} catch (RemoteException e) {throw new RuntimeException("Package manager has died", e);}}}}

注意:

注意:此修改方法对Google Now Launcher(GoogleHome.apk)无效。


[RK3399-Android9.0] 多个Launcher设置其中一个为默认桌面并且不显示桌面启动器弹窗相关推荐

  1. Rk3399 Android9.0 恢复出厂设置流程

    Reset 流程 : 1.原生设置中响应 恢复出厂设置 功能,继而发出重置广播(Intent.ACTION_FACTORY_RESET) . 2.frameWork层 接收到此广播,根据广播所携带的参 ...

  2. android9.0修改锁屏界面的锁屏图标在界面的显示位置

    Android默认的锁屏界面,相机,电话和锁屏图标都是默认放在屏幕下方的,MTk方案接到需求,把锁屏的图标放在屏幕的上方. 直接上代码,分析过程就不过阐释了.

  3. linux显示桌面命令,linux显示桌面快捷键设置

    HDU 1698 区间更新 Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  4. Android:Android9.0使用 AndroidVideoCache时不能缓存播放视频的解决

    一.问题现象: 项目中使用 https://github.com/danikula/AndroidVideoCache 作为视频缓存组件,但是在9.0手机上无法正常缓存,并且报错: 1.详细错误截图 ...

  5. 计算机设置了桌面显示为什么没有反应,电脑开机后只显示桌面背景,图标没有,鼠标也没有反应,怎么办?...

    电脑开机后只显示桌面背景,图标没有,鼠标也没有反应,怎么办?以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 电脑开机后只 ...

  6. Android9.0 Launcher启动Activity详解(一)

    一.开始 Launcher中点击应用图标启动Activity,其开始方法是 public boolean startActivitySafely(View v, Intent intent, Item ...

  7. 如何让APP不在设置中的应用列表中显示(MTK6757 Android9.0 )

    如何让APP不在设置中的应用列表中显示(MTK6757 Android9.0 ) 自己开发了一个APP,不想让APP在设置中的应用列表张显示APP图标,该如何操作呢? \vendor\mediatek ...

  8. Android10.0系统启动之Launcher(桌面)启动流程-[Android取经之路]

    摘要:上一节我们讲完了Android10.0的ActivityManagerService的启动流程,在AMS的最后启动了Launcher进程,今天我们就来看看Launcher的真正启动流程. 阅读本 ...

  9. android serialport new 软件退出_基于Android9.0,了解Android启动流程

    先记住四个进程和三种方式. **四个进程** 1.Launcher进程 2.system_server进程 3.App进程 4.Zygote进程 **三种方式** 1.Binder方式 2.Socke ...

最新文章

  1. Linux下运行run文件
  2. Centos7 Docker 安装与启动_入门试炼01
  3. pvrect r语言 聚类_R语言常用统计方法包+机器学习包(名称、简介)
  4. Spring Boot 自定义属性值
  5. Qt中图像的显示与基本操作
  6. 设计模式(十八):责任链模式
  7. python2020个税_2020年你会算个人所得税吗?没关系,python脚本帮助你!
  8. 用友U8 13.0运维及操作手册全版
  9. mysql类exadata功能_一些有用的Exadata诊断命令
  10. 深度学习系列资料总结
  11. 第三届同花顺算法大赛 | 2022 | AI算法
  12. 分布式数据库 Tracing (一)— Opentracing
  13. AFX_MANAGE_STATE(AfxGetStaticModuleState())
  14. 平面设计面试官常问的问题有哪些?
  15. 【python】录音语音识别
  16. 单边指数信号的傅立叶matlab,实验四连续信号的傅立叶变换
  17. 如何在优麒麟操作系统安装QQ、微信
  18. 骨龄仪存储卡损坏处理方案
  19. 有限元刚度矩阵的一维变带宽存储用C++实现(三)
  20. 毕业设计-城市公交线路查询系统

热门文章

  1. digit puzzle 数字谜 Uva12107
  2. 一生挚友redo log、binlog《死磕MySQL系列 二》
  3. Bringing machine ‘default‘ up with ‘hyperv‘ provider==> default: Verifying Hyper-V is enabled报错解决
  4. 基于Unity3D开发的智能巡逻兵小游戏
  5. js 实现全屏、退出全屏功能
  6. java/php/net/python儿童福利院信息管理网站设计
  7. 动漫企业为何集体逃离北京
  8. 【JAVA进阶】JVM第二篇- JVM 垃圾回收详解
  9. Linux常用命令——mkisofs命令
  10. 学计算机的人用的壁纸,桌面心理学:你的电脑桌面透露了什么?