当前位置:   article > 正文

Android MTK 设置默认启动 Launcher,字节跳动学习笔记_pm.gethomeactivities

pm.gethomeactivities

/**

  • mtk add

  • set default launcher

*/

ComponentName DefaultLauncher=new

ComponentName(“com.android.launcher3”,“com.android.launcher3.Launcher”); //此处设置默认Launcher的包

类名

//Slog.d(TAG,“set default launcher”);

final PackageManager mPm = mContext.getPackageManager();

ArrayList homeActivities = new ArrayList();

ComponentName currentDefaultHome = mPm.getHomeActivities(homeActivities);

ComponentName[]mHomeComponentSet = new ComponentName[homeActivities.size()];

for (int i = 0; i < homeActivities.size(); i++) {

final ResolveInfo candidate = homeActivities.get(i);

//Slog.d(TAG,“homeActivities”+candidate);

final ActivityInfo info = candidate.activityInfo;

ComponentName activityName = new ComponentName(info.packageName, info.name);

mHomeComponentSet[i] = activityName;

}

IntentFilter mHomeFilter = new IntentFilter(Intent.ACTION_MAIN);

mHomeFilter.addCategory(Intent.CATEGORY_HOME);

mHomeFilter.addCategory(Intent.CATEGORY_DEFAULT);

ListActivities=new ArrayList();

mPm.replacePreferredActivity(mHomeFilter, IntentFilter.MATCH_CATEGORY_EMPTY,mHomeComponentSet, DefaultLauncher);

/**

  • set default launcher end

*/

Intent intent = getHomeIntent();

ActivityInfo aInfo =

resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);

… PS:

二、如果预置了GMS,上面和下面

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/444087
推荐阅读
相关标签
  

闽ICP备14008679号