Services

地址:https://developer.android.com/guide/components/services.html#Basics html

为了确保你的应用安全,一般使用显示的方法来启动service,不要声明intent filters 给service。android

若是让service 支持intent filters而不用组件名称,必须在intent中设置包名setPackage(),安全

onStartCommand()必须返回一下的参量:ide

一、START_NOT_STICKYui

若是系统杀死了service,不会从新建立service,除非从新发送intent,component

二、START_STICKYhtm

若是系统杀死了service,会从新启动service,调用onStartCommand(),可是不会发送上一次的intent,系统调用onStartCommand()时intent为null,get

三、START_REDELIVER_INTENTgui

若是系统杀死了service,会从新建立service,并调用onStartCommand(),而且会传上一次的intent。service

相关文章
相关标签/搜索