时间:2020/12/03
之前公司不允许csdn,笔记写在其它地方。最近整理过来
前言
加载流程之前写过很多文章,加载流程(一)有兴趣的可以看看。
本文主要介绍一下launcher是怎么查询到各种图标或者快捷方式或者widget的。
1、 loadWorkspace
2、 loadAllApps
com/android/server/pm/LauncherAppsService
1、queryActivitiesForUser
2、new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_LAUNCHER)
3、loadDeepShortcuts
1、hasHostPermission--defaultLauncher
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts"/>
com/android/server/pm/ShortcutPackage
4、widgetsModel.update(mApp
1、加载widgets数据
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_build" />
2、加载shortcut数据
<action android:name="android.intent.action.CREATE_SHORTCUT" />
5、三方应用创建launcher上的shortcut
<activity android:name="com.android.launcher3.dragndrop.AddItemActivity"
android:theme="@style/AppItemActivityTheme"
android:excludeFromRecents="true"
android:autoRemoveFromRecents="true"
android:label="@string/action_add_to_workspace" >
<intent-filter>
<action android:name="android.content.pm.action.CONFIRM_PIN_SHORTCUT" />
<action android:name="android.content.pm.action.CONFIRM_PIN_APPWIDGET" />
</intent-filter>
</activity>
结尾
创建快捷方式的广播好像有变化
com.android.launcher.action.INSTALL_SHORTCUT 变成 android.content.pm.action.CONFIRM_PIN_SHORTCUT
网上其它相关的文章:
https://blog.youkuaiyun.com/u011484134/article/details/80443177
https://blog.youkuaiyun.com/dax120/article/details/78905334

本文详细介绍了Android系统中Launcher如何查询和加载应用图标、快捷方式以及Widget,涉及到的关键步骤包括loadWorkspace、loadAllApps过程,通过Intent查询活动,加载深色快捷方式以及更新Widgets模型。文章还提到了三方应用创建launcher快捷方式的方法以及相关广播动作的变化。
5016

被折叠的 条评论
为什么被折叠?



