我希望有一个必须永远活跃的broadcastReceiver(100%).现在,如果我在Android清单中注册了这种情况,那么当应用程序本身被AndroID框架销毁时它会被杀死吗?
现在,我也有一个在前台运行的服务.这会确保我的应用程序永远不会被销毁吗?反过来,这将确保我在AndroID清单中注册的接收器将永远保持活动状态.
解决方法:
清单上的broadcastReceiver(docs)始终处于活动状态,即使活动不再运行,它仍然有效(想想每次打开手机时触发的意图动作androID.intent.action.BOOT_COMPLETED的接收器).
定义和注册dinamically的接收器仅在应用程序运行时工作(例如LocalBroadcastManager的registerReceiver(…)方法).
见receiver element documentation,其中说明:
Declares a broadcast receiver (a broadcastReceiver subclass) as one of
the application’s components. broadcast receivers enable applications
to receive intents that are broadcast by the system or by other
applications, even when other components of the application are not
running.
Documentation about services说:
A foreground service is a service that’s consIDered to be something
the user is actively aware of and thus not a candIDate for the system
to kill when low on memory
因此,系统可能不会终止服务引用的正在运行的应用程序.
所以它只是能够阅读文档,我认为这是关于AndroID平台的超级详尽.
总结以上是内存溢出为你收集整理的android – 广播接收器的生命周期全部内容,希望文章能够帮你解决android – 广播接收器的生命周期所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)