在发广播时加入Intent.FLAG_RECEIVER_REGISTERED_ONLY
Intent i=new Intent("spdif_cable_status");
i.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
context.sendBroadcast(i);
然后在AndroidMainfest.xml文件中注册
<receiver android:name=".SpdifReciver" android:enabled="true" >
<intent-filter>
<action android:name="spdif_cable_status" />
<category android:name="android.intent.category.default" />
</intent-filter>
</receiver>
结果收不到广播,这个是为什么,在AndroidMainfest.xml文件中注册不算注册吗
Intent i=new Intent("spdif_cable_status");
i.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
context.sendBroadcast(i);
然后在AndroidMainfest.xml文件中注册
<receiver android:name=".SpdifReciver" android:enabled="true" >
<intent-filter>
<action android:name="spdif_cable_status" />
<category android:name="android.intent.category.default" />
</intent-filter>
</receiver>
结果收不到广播,这个是为什么,在AndroidMainfest.xml文件中注册不算注册吗
有没有办法使在AndroidMainfest.xml文件中注册的receiver能接收到这样的消息
Intent i=new Intent();
i.setAction("spdif_cable_status");
context.sendBroadcast(i);
试试