if (resolveInfoList != null) {
int size = resolveInfoList.size();
for (int j = 0; j < size;) {
final ResolveInfo r = resolveInfoList.get(j);
if (!r.activityInfo.packageName.equals(examplePackageName)) {
resolveInfoList.remove(j);
size -= 1;
} else {
j++;
}
}
ComponentName[] set = new ComponentName[size];
ComponentName defaultLauncher = new ComponentName(
examplePackageName, exampleActivityName);
int defaultMatch = 0;
for (int i = 0; i < size; i++) {
final ResolveInfo resolveInfo = resolveInfoList.get(i);
set[i] = new ComponentName(
resolveInfo.activityInfo.packageName,
resolveInfo.activityInfo.name);
if (defaultLauncher.getClassName().equals(
resolveInfo.activityInfo.name)) {
defaultMatch = resolveInfo.match;
}
}
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_MAIN);
filter.addCategory(Intent.CATEGORY_HOME);
filter.addCategory(Intent.CATEGORY_DEFAULT);
addPreferredActivity2(filter, defaultMatch, set,
defaultLauncher);
}
}
// TChip ZJ Add Above for Default Launcher
2.添加以下函数:
public void addPreferredActivity2(IntentFilter filter, int match,
ComponentName[] set, ComponentName activity) {
Log.d(“debug_default”, “addPreferredActivity2 is called.”);
// writer
synchronized (mPackages) {
Slog.i(TAG, "Adding preferred activity " + activity + “:”);
filter.dump(new LogPrinter(Log.INFO, TAG), " ");
mSettings.editPreferredActivitiesLPw(0).addFilter(
new PreferredActivity(filter, match, set, activity, true));
scheduleWriteSettingsLocked();
}
}
3.修改PackageManagerService.java的函数findPreferredActivity:
(1)对removeMatches进行条件判断,在launcher时不remove:
if (!(intent.getAction() != null
&& intent.getAction().equals(intent.ACTION_MAIN)
&& intent.getCategories() != null && intent.getCategories()
.contains(intent.CATEGORY_HOME))) {
Slog.d(TAG, “launcher”);
} else {
if (removeMatches) {
pir.removeFilter(pa);
if (DEBUG_PREFERRED) {
Slog.v(TAG, "Removing match " + pa.mPref.mComponent);
}
break;
}
}
(2)
if (always && !pa.mPref.sameSet(query, priority)) {
Slog.i(TAG, "Result set changed, dropping preferred activity for "
intent + " type " + resolvedType);
if (DEBUG_PREFERRED) {
Slog.v(TAG, "Removing preferred activity since set changed "
pa.mPref.mComponent);
}
pir.removeFilter(pa);
// Re-add the filter as a “last chosen” entry (!always)
PreferredActivity lastChosen = new PreferredActivity(pa,
pa.mPref.mMatch, null, pa.mPref.mComponent, false);
pir.addFilter(lastChosen);
重要知识点下面是有几位Android行业大佬对应上方技术点整理的一些进阶资料。
高级进阶篇——高级UI,自定义View(部分展示)
UI这块知识是现今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!
面试题部分合集
今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!
[外链图片转存中…(img-GhPfLLpS-1643522362688)]
面试题部分合集
[外链图片转存中…(img-OzGcpAEx-1643522362689)]
本文已被CODING开源项目:《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》收录
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)