launcher数据加载(二)

时间:2020/12/03
之前公司不允许csdn,笔记写在其它地方。最近整理过来

前言

加载流程之前写过很多文章,加载流程(一)有兴趣的可以看看。
本文主要介绍一下launcher是怎么查询到各种图标或者快捷方式或者widget的。

1、 loadWorkspace

2、 loadAllApps

com/android/server/pm/LauncherAppsService
1、queryActivitiesForUser
2new 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.csdn.net/u011484134/article/details/80443177
https://blog.csdn.net/dax120/article/details/78905334

你可能感兴趣的:(launcher,#,launcherQ,android)