Android中程序的停止状态详细介绍
很多人遇到过广播收不到的问题,比如GooglePlay推广安装广播没有收到等,诸如这些问题,又都是什么原因呢,这篇文章将进行回答.
从Android3.1(HoneyComb)也就是API12开始,Android引入了一套新的启动控制,这就是程序的停止状态.那让我们看一下Google对于程序的停止状态的描述.
什么是程序的停止状态
StartingfromAndroid3.1,thesystem'spackagemanagerkeepstrackofapplicationsthatareinastoppedstateandprovidesameansofcontrollingtheirlaunchfrombackgroundprocessesandotherapplications.
从Android3.1开始,系统的包管理器开始跟踪处理停止状态的程序.并且提供了方法来控制从后台进程或者其他程序对它们的启动.
Notethatanapplication'sstoppedstateisnotthesameasanActivity'sstoppedstate.Thesystemmanagesthosetwostoppedstatesseparately.
注意程序的停止状态和Activity的停止状态不同,系统会单独处理这两种状态.
TheplatformdefinestwonewintentflagsthatletasenderspecifywhethertheIntentshouldbeallowedtoactivatecomponentsinstoppedapplication.Android平台提供了两个intentflags,用来让发送广播的一方决定广播是否需要同时发送给已经停止的程序.
FLAG_INCLUDE_STOPPED_PACKAGES—Includeintentfiltersofstoppedapplicationsinthelistofpotentialtargetstoresolveagainst.将已经支持的程序加入到能处理intent的目标处理者.
FLAG_EXCLUDE_STOPPED_PACKAGES—Excludeintentfiltersofstoppedapplicationsfromthelistofpotentialtargets.在能处理intent的目标处理者中不包含已经停止的程序.