许多互联网文章都描述了如何通过提高服务优先级,用Android :优先级=“1000”来提供服务的生存时间。 其实是没有效果的做法。 (具体做法请参考能否实现服务不被kill。 )
关于priority属性的说明,谷歌官方文档如下。
安卓:预投
theprioritythatshouldbegiventotheparentcomponentwithregardtohandlingintsofthetypedescribedbythefilter.thisattributehasmeasmeate
itprovidesinformationabouthowableanactivityistorespondtoanintentthatmatchesthefilter, relativetootheractivitiesthatcouldalsorespondtotheintent.whenanintentcouldbehandledbymultipleactivitieswithdifferentpriorioritioritiorititiiion ronlythosewithhhigherpriorityvaluesaspotentialtargetsfortheintent。
itcontrolstheorderinwhichbroadcastreceiversareexecutedtoreceivebroadcastmessages.thosewithhhigherpriorityvaluesarecalledbefored it ' signoredforasynchronousmessages.)
usethisattributeonlyifyoureallyneedtoimposeaspecificorderinwhichthebroadcastsarereceived,orwanttoforceandroidtopreferoneactioneaction
The value must be an integer,suchas ' 100 '.highernumbershaveahigherpriority.thedefaultvalueis0. thevaluemustbegreaterthan -。
also see集优先级()。
1 .描述优先级概念控件的intent过滤器的类型。 此属性仅对activity和receivers有意义。
2 .隐式调用活动:当多个活动满足响应条件时,系统只触发优先级较高的活动。
3 .有序广播:当多个接收方满足响应条件时,系统优先触发优先级IT正在做的接收方。
4 .优先级必须是整数,默认值为0的范围为[-1000,1000 ]