平台放开BOOT_COMPLETED广播接收

android3.1以后开机自启动受限制,没有手动启动过的程序,收不到开机广播

修改方法:

在AMS发BOOT_COMPLETED广播的地方加上intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES已经停止的应用也收能收到这个广播

注意事项:

1.安装在sdcard的应用收不到广播,sdcard挂载晚

2.系统开启了FastBoot模式,系统启动并不会发送BOOT_COMPLETED广播

3.自启动时间晚,可以调高广播接收的优先级

<intent-filterandroid:priority="1000">

//可以提前开机自启动时间-1000----1000

<actionandroid:name="android.intent.action.BOOT_COMPLETED"/>

</intent-filter>

android:priority

Theprioritythatshouldbegiventotheparentcomponentwithregardtohandlingintentsofthetypedescribedbythefilter.Thisattributehasmeaningforbothactivitiesandbroadcastreceivers:

Itprovidesinformationabouthowableanactivityistorespondtoanintentthatmatchesthefilter,relativetootheractivitiesthatcouldalsorespondtotheintent.Whenanintentcouldbehandledbymultipleactivitieswithdifferentpriorities,Androidwillconsideronlythosewithhigherpriorityvaluesaspotentialtargetsfortheintent.

Itcontrolstheorderinwhichbroadcastreceiversareexecutedtoreceivebroadcastmessages.Thosewithhigherpriorityvaluesarecalledbeforethosewithlowervalues.(Theorderappliesonlytosynchronousmessages;it'signoredforasynchronousmessages.)

Usethisattributeonlyifyoureallyneedtoimposeaspecificorderinwhichthebroadcastsarereceived,orwanttoforceAndroidtopreferoneactivityoverothers.

Thevaluemustbeaninteger,suchas"100".Highernumbershaveahigherpriority.Thedefaultvalueis0.Thevaluemustbegreaterthan-1000andlessthan1000.

AlsoseesetPriority().

相关推荐