开始的时候很纳闷,为什么会这样了,然后就搜索了下,发现其实文档早就告诉我了,只不过英文差,没看仔细。。。
原文如下:
int | START_NOT_STICKY | Constant to return from : if this service's process is killed while it is started (after returning from ), and there are no new start intents to deliver to it, then take the service out of the started state and don't recreate until a future explicit call to . |
http://developer.android.com/reference/android/app/Service.html#START_STICKY
相信大家都是知道onStartCommand是有返回值的,这货真心是有用的,为的是告诉系统这后台服务要怎么存活着,其实英文不好的也可以慢慢看的,看着看着就懂了
本人遇到的问题,简单翻译过来就是,系统会重启app的服务,重启的时候intent就是空的,自己要做好判断。。。