赞
踩
/**
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);
/**
*/
Intent intent = getHomeIntent();
ActivityInfo aInfo =
resolveActivityInfo(intent, STOCK_PM_FLAGS, userId);
… PS:
二、如果预置了GMS,上面和下面
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。