public static voID setDefaultHome(Context context) { PackageManager packageManager = context.getPackageManager(); final Componentname component = Constants.HOME_COMPONENTname; final List<ResolveInfo> homeActivitIEs = new ArrayList<>(); packageManager.getHomeActivitIEs(homeActivitIEs); final List<Componentname> allComponents = new ArrayList<>(); for (ResolveInfo info : homeActivitIEs) { final ActivityInfo appInfo = info.activityInfo; Componentname activityname = new Componentname(appInfo.packagename, appInfo.name); allComponents.add(activityname); } // 利用 PackageManager 设置默认主页 packageManager.replacePreferredActivity( HOME_FILTER, IntentFilter.MATCH_category_EMPTY, allComponents.toArray(new Componentname[0]), component); // Launch the new Home app so the change is immediately visible even if // the Home button is not pressed. // 跳转到主页 if (true) { // 不能再次启动 Launcher,影响开机时间,再次启动会多耗时 4s+ return; } Intent intent = new Intent(Intent.ACTION_MAIN); intent.addcategory(Intent.category_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivityAsUser(intent, UserHandle.CURRENT); }
总结 以上是内存溢出为你收集整理的Android 系统开机时间优化全部内容,希望文章能够帮你解决Android 系统开机时间优化所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)