您的位置:首页 > 其它

Service的onStartCommand中intent null point的问题

2014-11-13 16:28 429 查看
开始的时候很纳闷,为什么会这样了,然后就搜索了下,发现其实文档早就告诉我了,只不过英文差,没看仔细。。。

原文如下:

intSTART_NOT_STICKYConstant to return from
onStartCommand(Intent,
int, int)
: if this service's process is killed while it is started (after returning from
onStartCommand(Intent,
int, int)
), 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
Context.startService(Intent)
.
http://developer.android.com/reference/android/app/Service.html#START_STICKY
相信大家都是知道onStartCommand是有返回值的,这货真心是有用的,为的是告诉系统这后台服务要怎么存活着,其实英文不好的也可以慢慢看的,看着看着就懂了

本人遇到的问题,简单翻译过来就是,系统会重启app的服务,重启的时候intent就是空的,自己要做好判断。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: