关于launcher3 应用icon会自动添加到待机页面的问题

在android系统开发过程中。发现有些应用在安装后,在主菜单中第一次进入之后,此应用的icon会自动加载到待机页面上。
通过launcher3源码发现。
在AndroidManifest.xml中

    <!-- Intent received used to install shortcuts from other applications -->
    <receiver
    android:name="com.android.launcher3.extension.MockInstallShortcutReceiver"
        android:permission="com.android.launcher.permission.INSTALL_SHORTCUT">
        <intent-filter>
            <action android:name="com.android.launcher.action.INSTALL_SHORTCUT" />
        </intent-filter>
    </receiver>

launcher3 静态注册了 com.android.launcher.action.INSTALL_SHORTCUT 广播。
有些应用,如微信等在第一次进入后,会想系统发上面的广播。
launcher3 在接收到此广播后会将此icon加载到待机页面。

public class InstallShortcutReceiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent data) {
        if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) {
            return;
        }

        PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, context);
        if (info.launchIntent == null || info.label == null) {
            if (DBG) Log.e(TAG, "Invalid install shortcut intent");
            return;
        }

        info = convertToLauncherActivityIfPossible(info);
        queuePendingShortcutInfo(info, context);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值