Android : android.intent.action.BOOT_COMPLETED on

2019-05-05 04:18发布

问题:


My application is listening to android.intent.action.BOOT_COMPLETED..

Android :2.3

i am able to get the broadcast when my application is Shut/Active before Boot up.


Android : 4.0.3

I am not able to get the broadcast when my application is Shut(Force Close) before Boot up. Reason is as in this link

Starting with 3.1 when applications are installed they are in a “stopped” state so they will not be able to run until the user explicitly launches them. Pressing Force Stop will return them to this state.

How do i Over Come this??I want to get the broadcast android.intent.action.BOOT_COMPLETED when the application is Shut as well.

Please help!!!

回答1:

The only way is that user should open your app explicitly.



回答2:

add this flag

intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);

I think it will work. Because i have faced the same problem.