将 <data android:scheme="package" /> 添加到 PACKAGE_ADDED 和 PACKAGE_REMOVED 后,单个接收器中的多个广播操作不起作用

Multiple broadcast Actions in single receiver not working After adding <data android:scheme="package" /> with PACKAGE_ADDED and PACKAGE_REMOVED

我正在创建一个应用程序,它将向我发送各种操作的事件, 我在单个 class 中添加了波纹管事件,它运行良好。

<receiver android:name=".activity.SettingsEventReceiver" >
    <intent-filter>
        <!--*************Bluetooth*********************-->
        <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />

        <!--*************Hotspot*********************-->
        <action android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />

        <!--*************AirplaneMode*********************-->
        <action android:name="android.intent.action.AIRPLANE_MODE"/>

        <!--*************VolumeChange*********************-->
        <action android:name="android.media.VOLUME_CHANGED_ACTION" />

        <!--*************ChargingSettings*********************-->
        <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
        <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />

        <!--*************Sim status changed Event*********************-->
        <action android:name="android.intent.action.SIM_STATE_CHANGED" />

        <!--*************Reboot Event*********************-->
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <category android:name="android.intent.category.DEFAULT" />
        <action android:name="android.intent.action.QUICKBOOT_POWERON"/>

    </intent-filter>
</receiver>

但是每当我添加波纹管动作时,我都没有收到一个事件

<!--*************Install/Uninstall Event*********************-->
    <action android:name="android.intent.action.PACKAGE_ADDED"/>
    <action android:name="android.intent.action.PACKAGE_REMOVED"/>
    <action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH"/>
    <data android:scheme="package" />

我该如何克服这个问题? 请帮忙

当您将 <data> 元素添加到 <intent-filter> 时,您将只会收到与该 <data> 元素匹配的广播事件。您列出的大多数广播 Intent 不包含任何数据。

你可以指定多个<intent-filter>,像这样:

<receiver android:name=".activity.SettingsEventReceiver" >
    <intent-filter>
        <!--*************Bluetooth*********************-->
        <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />

        <!--*************Hotspot*********************-->
        <action android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />

        <!--*************AirplaneMode*********************-->
        <action android:name="android.intent.action.AIRPLANE_MODE"/>

        <!--*************VolumeChange*********************-->
        <action android:name="android.media.VOLUME_CHANGED_ACTION" />

        <!--*************ChargingSettings*********************-->
        <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
        <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />

        <!--*************Sim status changed Event*********************-->
        <action android:name="android.intent.action.SIM_STATE_CHANGED" />

        <!--*************Reboot Event*********************-->
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <category android:name="android.intent.category.DEFAULT" />
        <action android:name="android.intent.action.QUICKBOOT_POWERON"/>

    </intent-filter>

    <intent-filter>
        <!--*************Install/Uninstall Event*********************-->
        <action android:name="android.intent.action.PACKAGE_ADDED"/>
        <action android:name="android.intent.action.PACKAGE_REMOVED"/>
        <action android:name="android.intent.action.PACKAGE_FIRST_LAUNCH"/>
        <data android:scheme="package" />
    </intent-filter>
</receiver>