Android 为什么接收者不回应?

Android 为什么接收者不回应?,android,plugins,broadcastreceiver,Android,Plugins,Broadcastreceiver,在我的应用程序myApp1中,我只有一个接收器 <receiver android:name="com.plugins.Plugin"> <intent-filter android:priority="1000" > <action android:name="Plugin.Broadcast" /> </intent-filter> </receiver> 它没有回应。若我在myApp1中添

在我的应用程序myApp1中,我只有一个接收器

<receiver
    android:name="com.plugins.Plugin">
    <intent-filter android:priority="1000" >
        <action android:name="Plugin.Broadcast" />
    </intent-filter>
</receiver>
它没有回应。若我在myApp1中添加了一些具有启动器类别的活动,那个么在安装myApp1之后运行主操作,然后接收器工作。 为什么会这样?我怎样才能修好它

答复: 为了确保广播被接收,我需要在我的意图中添加标志:

 i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
从Android 3.0(蜂巢)开始,由于安全原因,应用程序在启动(也就是说,某项活动已启动)至少一次之前无法接收广播

这样做是为了防止恶意应用程序在常见广播上安装和自动运行,如
BOOT\u COMPLETED
BATTERY\u CHANGED


因此,只有在myApp1中至少打开过一次UI的情况下,myApp1中的接收器才能工作。

@user1807110它准确地回答了您的问题。你们觉得遗漏了什么?“我怎样才能修复它?”-我在网上找到答案。
 i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);