不能接收广播的包装意图意图

2023-09-06 04:06:29 作者:最清晰的声

我想注册一个广播接收器来接收广播事件的包事件。以下是code和我在清单文件接收器。日志说明书从未发生过,但我可以清楚地看到同一个广播发射的HomeLoaders(启动器)调试语句。我在想什么?

 公共类IntentListener扩展的BroadcastReceiver {

    @覆盖
    公共无效的onReceive(上下文的背景下,意图意图){
        // TODO自动生成方法存根
        Log.i(意图听者:intent.getAction());
    }
}

<接收器的Andr​​oid版本:NAME =IntentListener机器人:启用=真正的机器人:出口=真正的>
    <意向滤光器>
        <数据机器人:计划=一揽子>< /数据>
        <作用机器人:名称=android.intent.action.PACKAGE_ADDED>< /作用>
        <作用机器人:名称=android.intent.action.PACKAGE_ADDED>< /作用>
        <作用机器人:名称=android.intent.action.PACKAGE_CHANGED>< /作用>
    &所述; /意图滤光器>
< /接收器>
 

解决方案

这是可能的,这些意图 S不能在清单中注册的组件接受,但只能通过通过 registerReceiver在Java中注册的接收器()

I am trying to register a Broadcast Receiver to receive broadcast events for the package events. Following is the code and my receiver in the manifest file. The log statment never happens, but I can clearly see the same broadcast firing for "HomeLoaders" (the Launcher) debug statements. What am I missing?

public class IntentListener extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Log.i("INTENT LISTNER:", intent.getAction());
    }
}

<receiver android:name="IntentListener" android:enabled="true" android:exported="true">
    <intent-filter>
        <data android:scheme="package"></data>
        <action android:name="android.intent.action.PACKAGE_ADDED"></action>
        <action android:name="android.intent.action.PACKAGE_ADDED"></action>
        <action android:name="android.intent.action.PACKAGE_CHANGED"></action>
    </intent-filter>
</receiver>
Android蓝牙通讯接收到的数据是一段一段的,不能连起来,什么原因

解决方案

It is possible that these Intents cannot be received by components registered in the manifest, but only by receivers registered in Java via registerReceiver().