In Android development, many applications for various purposes, want to wake up when the machine starts, the general practice is to write a broadcastreceiver, receive the corresponding boot action, of course, do not forget to add permission in manifest " Android.permission.RECEIVE_BOOT_COMPLETED ". But recently in the 4.0 development, some colleagues claimed that the broadcast was not received, while others said their own can receive, what is the matter.
It turns out that after 3.1, the system's Package manager adds management to the "Stopped state" application, which is completely different from the stop status in the stopped and activity lifecycle. Refers to an application that has never been started after installation and is manually forced to stop by the user, while the system adds 2 flag:flag_include_stopped_packages and Flag_exclude_stopped_packages, To identify whether a intent activates an app that is in "stopped state". When 2 flags are not set or are set, the Flag_include_stopped_packages effect is used.
With the new mechanism above, Google think to all the broadcast intent default plus flag_exclude_stopped_packages will be very cooooool, to a certain extent, to avoid the rogue software, virus ah bad, but also to improve efficiency, Causes the problem in the topic of this article, receive_boot_completed broadcast if the user has not run the application, it will not respond.
But Google still leaves room to allow apps and backend services to wake up the STOPPED state program by setting Flag_include_stopped_packages to broadcast intent. That is, users write their own broadcast intent can control this mechanism, but the system comes with the broadcast intent, because can not be modified, can only accept the reality.
In the 3.1 update document, you can find instructions for the above changes: Http://developer.android.com/sdk/android-3.1.html#launchcontrols
Android3.1 after boot_completed broadcast does not respond to the problem