Analysis of the problem that the Android4.0 system does not receive the broadcast

Source: Internet
Author: User

After 3.1, the system's package manager adds to the management of 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 has left a bit of room for custom broadcasts that we can

SetFlags (Intent.flag_include_stopped_packages), this method to wake up in the "STOPPED state" of the program, that is, users write their own broadcast Intent can control this mechanism, But the system comes with the broadcast intent, because cannot modify, can only accept this reality

For example:

Intent startintent = new Intent ();
Startintent.putextra ("pkg", Getpackagename ());
Startintent.setaction ("Com.lenovo.speechcamera.start");
Startintent.setflags (intent.flag_include_stopped_packages);
Sendbroadcast (startintent);

Analysis of the problem that the Android4.0 system does not receive the broadcast

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.