且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从ADB安装后,静态BroadcastReceiver无法正常工作

更新时间:2023-02-02 19:17:32

最后得到了解决。

自从Honeycomb以来,所有新安装的应用程序将进入 STOP 阶段,直到至少启动一次。 Android为所有广播意图添加一个标志 FLAG_EXCLUDE_STOPPED_PACKAGES ,这将阻止它们到达已停止的应用程序。
http: //droidyue.com/blog/2014/01/04/package-stop-state-since-android-3-dot-1/

Since Honeycomb, all the freshly installed apps will get into a STOP stage until they are launched for at least one time. Android adds a flag "FLAG_EXCLUDE_STOPPED_PACKAGES" for all broadcast intents, which stops them from reaching the stopped apps. http://droidyue.com/blog/2014/01/04/package-stop-state-since-android-3-dot-1/

到要解决此问题,只需将标记 FLAG_INCLUDE_STOPPED_PACKAGES 添加到我们发送的意图中即可。就我而言,我将adb命令修改为

To solve this issue, just simply add the flag "FLAG_INCLUDE_STOPPED_PACKAGES" to the intents we send. In my case, I modify the adb command as

adb shell am broadcast -a com.example.demo.action.LAUNCH --include-stopped-packages