public class test extends BroadcastReceiver {
@ Override
public void onReceive (Context context, Intent intent) {
/ / TODO Auto-generated method stub
Toast.makeText (context, "boot broadcasting", 1) show ();.
}
}
-------------------------------------------------- ------------
-----------------------------------------
Can not run on a 4.0 system. 2.3.6 in the system. Why. I used the Samsung 9100,4.0 system testing can not.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
4.0.3 broadcast on the simulator systems can not. In the end is why? ? ? ?
What is not to add the code? ? ?
Online anxious
Reply:
Used properly, is how a landlord can not ah?
Reply:
No method into my radio inside. Simulator you can do? I tested the boot broadcast messages can not receive broadcast ah! 4.0 can not be 2.2. You see there is anything wrong with my code
Reply:
Android 4.0 reasons someone can not receive broadcast messages to resolve the matter yet
Reply:
Reply:
I encountered this problem, is 4.0 to cancel the non-activity threading issues. Trouble ah
Reply:
Then how things right.
Reply:
Will someone solve this issue under it, bother me a long time
Reply:
Will someone solve this issue under it, bother me a long time
Reply:
Do not sink it ah! Some people know what to say about the class
Reply:
android 4.0 In order to prevent some malware (malicious software) without the user starts it running in the background, the default installation of the program before the user starts the system is completely ignored, even if the procedures for the registration of the radio, the system does not give the program passes broadcasts. Only after the user runs the program is over, the message broadcast to take effect. Moreover, even if the program has been run over, if the user Force Stop (forced stop), the system will return to the state of being ignored. This problem is actually from 3.1 when it already has, most recently with the 4.0 system testing discovered the existence of the problem, causing a lot of trouble.
Reply:
After 3.1, package manager system adds support for in "stopped state" application management, this stopped and Activity lifecycle stop state is entirely different things, means that after the installation has never been started and was forced to stop in the user manual applications at the same time the system increases the two Flag: FLAG_INCLUDE_STOPPED_PACKAGES and FLAG_EXCLUDE_STOPPED_PACKAGES, to identify whether an intent to activate in "stopped state" applications. When the two Flag is not set or is set when using a FLAG_INCLUDE_STOPPED_PACKAGES effect.
With the new system after the above, google feel all broadcast intent to default plus FLAG_EXCLUDE_STOPPED_PACKAGES will be very Cooooool, to avoid rogue software to some extent, the virus ah do bad things, but also improve efficiency, has led to the title of this article says The problem, RECEIVE_BOOT_COMPLETED broadcast over the application if the user is not running, it will not respond.
But google still left a little room for the broadcast custom we can
setFlags (Intent.FLAG_INCLUDE_STOPPED_PACKAGES); this method to wake up in the "stopped state" of the program, that is, the user can write their own broadcast intent to control this mechanism, but the system comes with a broadcast intent, because it is not modified, it can only accept this reality the
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);
No comments:
Post a Comment